[Xapian-discuss] Multiple filters with PHP? How to?
James Aylett
james-xapian at tartarus.org
Tue Jan 8 19:20:10 GMT 2008
On Tue, Jan 08, 2008 at 10:59:42AM -0800, athlon athlonf wrote:
> I tried this and expect to have the results on category 68 with author 5.
>
> $query_string = $_POST['terms'];
> $query = $qp->parse_query($query_string);
> $queryarr[] = new XapianQuery(XapianQuery_OP_FILTER,$query, new XapianQuery('G68'));
> $queryarr[] = new XapianQuery(XapianQuery_OP_FILTER,$query, new XapianQuery('XAUTHORID5'));
> $query = new XapianQuery(XapianQuery_OP_AND,$queryarr);
> print "Parsed query is: " . $query->get_description(). "<br/>";
You don't really want to do it that way round; you've constructed a
query (or tried to) that has two sides ANDed together, each filtering
the initial query through one of your boolean terms. Instead, you want
to filter the query through an AND of your boolean terms. Something
like (forgive the probably inaccurate PHP):
----------------------------------------------------------------------
$query_string = $_POST['terms'];
$probquery = $qp->parse_query($query_string);
$filter = new XapianQuery(XapianQuery_OP_AND, new XapianQuery('G68'),
new XapianQuery('XAUTHORID5'));
$query = new XapianQuery(XapianQuery_OP_FILTER, $probquery, $filter);
print "Parsed query is: " . $query->get_description(). "<br/>";
----------------------------------------------------------------------
(There may be a way of doing that faster by constructing the $filter
without intemediate XapianQuery objects, but I can't remember what's
available in the PHP bindings.)
J
--
/--------------------------------------------------------------------------\
James Aylett xapian.org
james at tartarus.org uncertaintydivision.org
More information about the Xapian-discuss
mailing list