[Xapian-discuss] Trouble understanding MultiValueSorter with PHP bindings

Olly Betts olly at survex.com
Thu Aug 13 04:53:08 BST 2009


On Wed, Aug 05, 2009 at 12:50:38PM -0400, Jason Chapin wrote:
> My understanding of 
> $sorter->add(2) is to sort the results on the third field of the 
> document (field 0 being the docId and field 3 being the second field 
> defined in the scriptindex file used to build the database).

No, that's incorrect.  The argument of Sorter::add() is the number of a
Document value slot.

With the API, you add these with Document::add_value().  With
scriptindex, you can add these with value=SLOT or valuenumeric=SLOT.
See:

http://xapian.org/docs/omega/scriptindex.html

As for sorting by docid as well, then note that this only makes sense as
the "least significant" ordering (since no two documents have the same
document id, sorting by docid then <anything> means that <anything>
never affects the ordering).

The docid is always used as the final decider anyway, but you can change
whether you want ascending, descending, or you don't care (in which case
you get whatever is most efficient).  In the API that is
Enquire::set_docid_order().  Doesn't seem to be accessible from
OmegaScript at present (but would be easy to add).

There's more discussion of sorting here:

http://xapian.org/docs/sorting

Cheers,
    Olly



More information about the Xapian-discuss mailing list