[Xapian-discuss] Category Search with Values

Tom Mortimer tom at lemurconsulting.com
Mon May 18 12:31:16 BST 2009


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

> 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:


Francesco,

The odd thing here is that you are specifying the filter term to be
"XCcategory1", but Xapian is reporting it as "XCcat1".  I can't tell from
your pasted code why this is happening. What is the actual term in the
database? If the query term doesn't match the indexed term exactly, there
will be no results.

Regarding your question about multiple filters, just use a different prefix
for each field. It's usual in Xapian for user-defined prefixes to start with
X, so you could have XC, XD, XFOO, etc etc.

Tom


More information about the Xapian-discuss mailing list