Internets Datoram
2011-Jul-07 04:50 UTC
[Xapian-discuss] return values in groups - price range groups
Hi colleagues, I have a simple product database indexed with Xapian. Amazing free tool, thanks you developer(s)! I need to have a way to return prices of products in groups, say I have prod prices: 1.01 1.03 10.01 250.44 260.33 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. Any tips how to go about this developing myself to minimise db load? Thank you guys! Andy
Olly Betts
2011-Jul-07 11:20 UTC
[Xapian-discuss] return values in groups - price range groups
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