[Xapian-discuss] Get Document Position in Search

Ryan Bates ryan at railscasts.com
Fri Jul 10 00:03:32 BST 2009

Thanks for your input!

I ended up working around this problem. Here's my solution for those

My situation is somewhat
unique, the results are sorted by name (not relevancy) and each name
is unique. This allows me to add an
or OP_VALUE_GE condition to the search (whether I want the previous or
next item
respectively). For example.
Xapian::Query.new(Xapian::Query::OP_VALUE_GE, sort_value_id, name)

That query just needs to be combined with the rest of the conditions to
fetch the next item.

It would be nice if this could be done with a Xapian relevancy as well. I
assume this is somewhat possible with Enquire::set_cutoff method which could
be used to fetch the previous record given a document's weight (?). But I
don't know of a way to fetch the next record in this manner because (AFAIK)
it is not possible to fetch all documents less than a given weight.


On Thu, Jul 9, 2009 at 3:19 PM, James Aylett <james-xapian at tartarus.org>wrote:

> On Thu, Jul 09, 2009 at 02:56:49PM -0700, Ryan Bates wrote:
> > In this situation the items are being edited at the same time (think of
> an
> > "edit next" button on a form). This spawns a background process which
> > updates the Xapian database within minutes, so the chances are quite high
> > the modifications will change the search results. Storing a simple offset
> > won't work here since it could easily skip records.
> Two options:
> 1. ignore the record skipping; this is cheap, and in most cases you'll
> get away with it
> 2. have the "next document" link contain the current doc id, and the
> page number, so you can at least start in roughly the right place
> Bear in mind that scrolling through a search result set (which is what
> prev/next buttons do) makes little sense if you also acknowledge the
> change in the results set anyway. The whole thing is invalidated (and
> Xapian currently doesn't have a way of holding the previous revision
> of the database indefinitely). So you have to compromise somewhere,
> it's just a matter of what makes the most sense to your users  :-)
> J
> --
>  James Aylett
>  talktorex.co.uk - xapian.org - uncertaintydivision.org
> _______________________________________________
> Xapian-discuss mailing list
> Xapian-discuss at lists.xapian.org
> http://lists.xapian.org/mailman/listinfo/xapian-discuss

More information about the Xapian-discuss mailing list