[Xapian-discuss] query within value range
mark.clarkson at smorg.co.uk
Tue Jun 5 16:23:56 BST 2007
On Tue, 2007-06-05 at 15:21 +0100, Richard Boulton wrote:
> 1) index your data storing the value you wish to sort by in a value (ie,
> not as a term). Sorting is only possible in string order, so if you
> want to store a number to sort by, this needs to be marshalled into a
> form in which numerical sort order is the same as string sort order: for
> integers in a known range (eg, dates), the easiest way to do this is to
> pad with leading zeros so that all the values are the same length.
> 2) assuming you're using the query parser, add a value-range processor
> to the parser using "add_valuerangeprocessor()". Supposing you're using
> a DateValueRangeProcessor, you'd might do something like:
> Then, a query like "20060501..20070503" will become a ValueRange query,
> returning only those documents for which the value in slot 1 is in the
> range 20060501 to 20070503.
> Note that value range processors don't use prefixes, so you don't need
> to specify "date:" in the query - the ".." is picked up as indicating a
> 3) If you're not using the query parser, you can build the value range
> query directly, using the OP_VALUE_RANGE operator (and an associated
Your excellent clear description is just what I needed. Thanks very
much. Would I be right in saying that there can be only one value range
item that can be used per query when using the query parser?
More information about the Xapian-discuss