[Xapian-discuss] Avoiding "stale" Search Results
Olly Betts
olly at survex.com
Wed May 20 04:00:32 BST 2009
On Mon, May 18, 2009 at 07:16:36PM -0700, Miki Tebeka wrote:
> I'm using the Python bindings to query a remote xapian-tcpsrv (xapian
> 1.1.0).
>
> Once I have the result set I can get the SearchResult objects from it.
Um, there isn't a class called "SearchResult" in Xapian.
> However if I wait a little bit and then try to access the result object I
> get the following error:
> DatabaseModifiedError: REMOTE:The revision being read has been discarded -
> you should call Xapian::Database::reopen() and retry the operation
>
> I guess this is due to a change in the database (there is another process
> adding documents).
Yes.
> Is there a way to tell xapain to cache locally the SearchResult objects so
> I won't need to call db.reopen() all the time?
Readers don't currently lock the revision they are using, so you have to
reopen() to move them on to a revision which actually still exists.
The main reason readers don't lock the revision is that nobody has
implemented it. There's also the issue that it makes it very easy to
inadvertently bloat the database with lots of old revisions. I'm not
sure there's a way to avoid that.
For now, I'd suggest just reading the results you want right away rather
than waiting a bit. It also helps to batch up writes more (which also
improves the efficiency of applying them) - see XAPIAN_FLUSH_THRESHOLD
for how to adjust the default flushing.
Cheers,
Olly
More information about the Xapian-discuss
mailing list