[Xapian-discuss] faceted searches

Alexander Lind malte at webstay.org
Sun Aug 26 21:50:54 BST 2007


Hi all

I've been thinking about implementing some faceting support in my Xapian 
classes.
Has anyone implemented anything like this before?   It seems like Omega 
does not support faceted searches, is this correct?

What I would like to do specifically, is issue a query like
"bicycle facet:color"

"color" would be a predefined list of different colors, say 'red, green, 
blue, yellow, white, black'.
The end result would be the same result set as the query 'bicycle' 
itself would yield, but it would also come with a list of counts - how 
many results we have for 'bicycle color:red', how many for 'bicycle 
color:green', and so on.
Several big sites have searches like this already.

I can think of two ways of achieving this with Xapian:

Alternative 1:
1. Perform main search (for bicycle).
2. Perform as many searches on the returned mset as there are facets (in 
this case all the colors).
3. Store the count for each color, and return it together with the 
search results from point 1.

Alternative 2:
1. Perform main search (for bicycle).
2. Iterate through the entire mset, counting occurrences of each color, 
and storing the counts.
3. Return counts and results from point 1.

Can anyone say if there are any pitfalls with either of these 
strategies?  Too slow, flawed logic, etc?
Can you suggest a better way of doing it?
Has it already been done with Xapian somewhere?

I'm leaning towards alternative 1, since iterating through say 5 million 
documents must be extremely slow.

Cheers
Alec



More information about the Xapian-discuss mailing list