[Xapian-discuss] Category Search with Values

Tom Mortimer tom at lemurconsulting.com
Mon May 18 11:19:12 BST 2009


2009/5/18 Senior Boss <seniorboss at hotmail.it>

> Hi, I hope that someone can help me. I have intention to use xapian for one
> portal of mine in which
> the consumers can post messages that are divided for category.
> When I index a new post I also add to the object document the value with
> the name of the category.
> How can I exploit all of this to effect searches filtered in base to the
> category?
> Is there another way to do it without using the meta-data value?


Hi Francesco,

If I understand you correctly, the usual way to do this would be to add a
term with a unique prefix to the document, e.g. (in pseudo-code):

  doc.add_term('XC' + category_name);
  ...
  db.add_document(doc);

Then for filtering searches, add a subquery with the OP_FILTER operator:

  filter_query = Query('XC' + category_name);
  query = Query(OP_FILTER, user_query, filter_query);

Hope this helps.

Tom


More information about the Xapian-discuss mailing list