[Xapian-discuss] collapsing by one value and sorting by another

Sascha Silbe sascha-ml-devel-xapian-discuss at silbe.org
Sat Oct 17 23:20:45 BST 2009


On Sat, Oct 17, 2009 at 10:36:55PM +0100, Olly Betts wrote:

>> I've found ways to use several sort keys (i.e. with the 2.+ only used 
>> if  the first returns equality), but nothing that would allow me to 
>> collapse  by a different value than the sort uses (values are often 
>> non-unique).
> Just pass a different value slot number for the sorting and 
> collapsing,
> for example:
>
>      enquire.set_sort_by_value(1);
>      enquire.set_collapse_key(2);

My description probably was not clear enough; there are actually three 
different values involved for each query:

1. Value grouping documents together (let's call it tree_id).
2. Value selecting the "best" match inside a group of documents (the 
timestamp)
3. Value for sorting the result (e.g. title)

Another value (let's call it version_id) uniquely identifies each single 
document ("version") inside a set of related documents (same tree_id). 
The Xapian document ID (used to modify or remove index entries) is a 
concatenation of tree_id and version_id.

Value 1 (tree_id) clearly is the collapse_key. But the sort_key would be 
value 2 (timestamp) for collapsing purposes and value 3 (e.g. title) for 
sorting the match set before applying offset/limit and returning to the 
application.

Hope this describes my problem better.

CU Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.xapian.org/pipermail/xapian-discuss/attachments/20091018/893e7102/attachment.pgp>


More information about the Xapian-discuss mailing list