[Xapian-discuss] Terminating a Xapian query
jf at dockes.org
Fri Sep 25 09:55:27 BST 2009
Richard Boulton writes:
> 2009/9/25 Jean-Francois Dockes <jf at dockes.org>
> > I am looking for a way to cancel a long-running Xapian query (when the
> > user gets bored).
> > Would throwing an exception inside a matchspy or matchdecider work
> > (cleanly) ?
> I don't see any particular reason that it wouldn't work cleanly.
> Another option, if you're using the development 1.1 releases, might be to
> use a PostingSource which normally returns all documents (with a weight of
> zero), but which you can make jump to the end when desired. Then, AND that
> with the query. This approach would allow you to obtain the results which
> had been calculated at the time you aborted.
I am not using 1.1 yet, so I tried the first approach, but there seems to
be a problem with it: if there are few or no candidate documents, the
MatchDecider is not called often or at all, and in consequence the time
after which the query can be cancelled is unpredictable. This would be a
problem for example when searching for a rare phrase made of common words
("to be or not to be").
Would the PostingSource approach avoid this issue ?
More information about the Xapian-discuss