[Xapian-discuss] How does the sorting of search result work in
Xapian?
Olly Betts
olly at survex.com
Fri Apr 6 10:37:05 BST 2007
On Thu, Apr 05, 2007 at 03:20:03PM -0400, Ram Peters wrote:
> Is there a way to limit search result data, for example to only past 7
> days or 30 days of documents that were created?
There are (at least) three techniques:
The oldest technique (as used in current releases of Omega) implements
date range filtering in very a different way - each document gets 3
terms for the date, e.g. for today:
Y2007
M200704
D20070406
And then the search builds up a filter using OR on a suitable set of
these terms, e.g. for 2005-12-31 to 2007-02-02 the filter would be:
D20051231 OR Y2006 OR M200701 OR D20070201 OR D20070202
This does create quite a lot of extra terms, but it works very well
in practice.
A more modern option is to subclass MatchDecider - this is called from
the matcher for each document which is a serious contender, and it can
look at the document values and say "yes" or "no". So if you store the
creation date in a document value, you can achieve what you want. In
SVN HEAD, Omega's datematchdecider.cc contains an implementation of this
approach.
Similar to MatchDecider is the very new OP_VALUERANGE Query operation
(also in SVN HEAD). This allows a query to be limited to a range of
values, and QueryParser can process user values to convert them to a
suitable format. There's a DateValueRangeProcessor for date values.
The really nice feature of this is that it's hooked into the
QueryParser, so to find any mention of "fish" last year you can enter
the query string:
fish 01/01/2006..31/12/2006
Cheers,
Olly
More information about the Xapian-discuss
mailing list