[Xapian-discuss] Searching for document-groups

Olly Betts olly at survex.com
Tue Nov 7 19:58:39 GMT 2006


On Tue, Nov 07, 2006 at 07:59:58PM +0100, Christoph Hack wrote:
> And now I am wondering how i can reduce the search results to
> entire threads and display posts with the same root-post just once.

If you add a value to each document (using Xapian::Document::add_value())
containing some sort of unique id for the root-post of the thread that
the current article is in, you can collapse matches with the same
root-post leaving just the highest ranking one.  You do this using
Xapian::Enquire::set_collapse_key() with the value number that holds the
root post unique id.

So pick a non-negative value for the rootid.  If you aren't using values
yet, it might as well be 0:

#define VALUE_ROOTID 0

At index time:

doc.add_value(VALUE_ROOTID, rootid);

At search time:

enquire.set_collapse_key(VALUE_ROOTID);

Cheers,
    Olly



More information about the Xapian-discuss mailing list