[Xapian-tickets] [Xapian] #452: Add support for sorting documents missing a value to end
Xapian
nobody at xapian.org
Mon Feb 22 13:53:26 GMT 2010
#452: Add support for sorting documents missing a value to end
-------------------------+--------------------------------------------------
Reporter: richard | Owner: richard
Type: enhancement | Status: new
Priority: normal | Milestone: 1.2.x
Component: Library API | Version: SVN trunk
Severity: normal | Blockedby:
Platform: All | Blocking:
-------------------------+--------------------------------------------------
Currently, when performing a sort in ascending order based on a value
slot, documents with no value stored in the slot will be placed highest
(since "" sorts before any other value). However, this is often not
desirable: in particular, if a numeric value such as price has been stored
in the slot, and sorting is in ascending price order, it is likely that
documents without a price stored shouldn't be ranked above the cheapest
products.
A KeyMaker subclass can easily be written to support this, but it would be
useful for there to be support in a standard KeyMaker (so that users of
languages like Python could use it). I have a patch attached which allows
MultiValueKeyMaker to be given a "default value" which is used in place of
the empty value for documents with no value stored. This is slightly more
flexible than simply sorting to the end; for example, the median price
stored could be tracked, and used to sort documents with no price stored
at this position, instead of simply sorting them to the end.
For backends which store an upper bound on the value in a slot, it is
trivial to compute a value which sorts after all other values in the slot
- just append a character to the upper bound.
The patch is fairly simple, and contains a few testcases. Exactly as
implemented it is probably ABI incompatible (it extends an API method with
a new parameter with a default argument), but it could be trivially
adjusted to use an overloaded method instead for ABI compatibility if
added during the 1.2.x series.
--
Ticket URL: <http://trac.xapian.org/ticket/452>
Xapian <http://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list