[Xapian-discuss] How to implement range searches?

Torsten Foertsch torsten.foertsch at gmx.net
Sun Nov 16 12:26:12 GMT 2008


Hi,

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?

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?

I think I have to store the values via $doc->add_value($valno, $value). 
But how do I tell the queryparser what value number to use for a given 
range? How do I tell it "a" is value number 3 and "b" is number 5?

Do I understand it correctly that the range search is applied after the 
actual search? Does it mean the query above would lead to a complete 
scan over all documents since there is no search word in the query? Or 
is there an index also on the value fields of the documents?

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.

Thanks,
Torsten



More information about the Xapian-discuss mailing list