[Xapian-discuss] How to implement range searches?
Olly Betts
olly at survex.com
Mon Nov 17 10:18:11 GMT 2008
On Sun, Nov 16, 2008 at 01:26:12PM +0100, Torsten Foertsch wrote:
> http://www.xapian.org/docs/queryparser.html states: "The QueryParser can
> be configured to support range-searching using document values."
>
> How to do that using the Perl API?
Much the same as in C++, except you can't currently create your own
subclasses in Perl - you are limited to the standard ones:
http://xapian.org/docs/valueranges.html
> I want to be able to search for "a:10..15 AND b:qaa..raa", that is find
> all documents where the value a is between 10 and 15 and b in the range
> qaa, qab, ..., qba, qbb, ..., qzz, raa.
>
> Is that possible?
Yes (intermediate values such as qaabcde will also match the latter).
> Do I understand it correctly that the range search is applied after the
> actual search?
Not really. The matching all happens together, but the matcher is
fairly smart about what order to do things in within that.
> Does it mean the query above would lead to a complete
> scan over all documents since there is no search word in the query?
Yes, and this can be a bit slow for such cases in 1.0.x.
> Or is there an index also on the value fields of the documents?
SVN trunk's chert backend stores values differently (much like how we
store term postings) and is much quicker.
> Background: I want to store in the index 2 values. One is a string
> handle that says what process has brought the document into the index
> or updated it recently. The other is a UNIX timestamp.
Does a range search really make sense on the first? If not, then
indexing as a boolean term may be more sensible. You can check for one
of several values still.
Cheers,
Olly
More information about the Xapian-discuss
mailing list