[Xapian-discuss] return values in groups - price range groups

Olly Betts olly at survex.com
Thu Jul 7 12:20:37 BST 2011


On Thu, Jul 07, 2011 at 07:50:43AM +0300, Internets Datoram wrote:
> I need to
> have a way to return prices of products in groups, say I have prod prices:
[...]
> I need to
> get it to return something like: 
> 
> Group 1 =
> 1.01 ? 1.03
> 
> Group 2 =
> 10.01
> 
> etc.
> 
> Maybe there
> is something build-in Xapian that can do this? I re-read the docs, but didn?t
> see it, still I thought it?s worth asking.

You can use a MatchSpy to extract all the prices which occur in the
matched documents:

http://xapian.org/docs/facets

Although it doesn't say so there, the values can be a more continuous
quantity like price, as well as discrete things like colour or product
type.

There's no support for building "buckets" by price in the released
version of this feature, so you'd have to implement that part.

There was something to do this in the original implementation, but it
didn't seem to do what users actually wanted, and the API was rather
complex, but it is still on the branch if you want to look - here's the
API header for it (the NumericRanges stuff towards the end is what
you're wanting):

http://trac.xapian.org/browser/branches/matchspy/xapian-core/include/xapian/matchspy.h

Cheers,
    Olly



More information about the Xapian-discuss mailing list