[Xapian-discuss] DISTINCT clause in Xapian?

James Aylett james-xapian at tartarus.org
Thu Aug 14 14:18:23 BST 2008


On Thu, Aug 14, 2008 at 03:02:00PM +0200, James Cauwelier wrote:

> I have a database of products with a indexed table, description, etc.   
> Every product has a publisher, price, availability property and can be  
> part of one or more product selections (just group of products).
> 
> When I query the Xapian database, I also want a list of unique  
> publishers for the product results.  In SQL, I would use a DISTINCT  
> clause to do this.  Currently, I cache Xapian results in a MySQL DB  
> table, but this introduces an extra step in the search mechanism and I  
> am having performance issues with this.
> 
> Can anybody point me to a solution for my problem?

You should be able to do this using a collapse key. Assuming each
Xapian document is a product, you can add a value giving the publisher
in some way (probably a numeric identifier), and use
Enquire::set_collapse_key() to do the work.

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list