[Xapian-discuss] Category Search with Values
Senior Boss
seniorboss at hotmail.it
Mon May 18 11:57:52 BST 2009
Hi Tom and thanks for the rapidity in to answer me. I have followed your indications and it is really what i'm looking for.
Unfortunately the search doesn't produce any result while in the db the searched record is present.
I insert here following the code that I have used (Php). Is there something of wrong?
For the indexer
$doc->add_term('XC'.$category);
...
$db->add_document($doc);
For the search
$user_query = "blu red";
$filter_query = "XCcategory1";
$query = new XapianQuery(XapianQuery::OP_FILTER, $user_query, $filter_query);
$enquire->set_query($query);
$matches = $enquire->get_mset(0, 10);
The output result is
Parsed query is: Xapian::Query((blu red FILTER XCcat1))
0 results found:
MESSAGGIO ORIGINALE
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
MESSAGGIO ORIGINALE
More information about the Xapian-discuss
mailing list