[Xapian-discuss] Searching Within A Specific Field (eg.
"title:reading") in PHP
Olly Betts
olly at survex.com
Tue Sep 4 03:08:23 BST 2007
On Wed, Jul 25, 2007 at 12:39:15PM -0400, Benny Chan wrote:
> Heres what my PHP code looks like;
>
> $query_parser = new_queryparser();
>
> //set the stemmer and turn on the stemming strategy
> queryparser_set_stemmer($query_parser, $stemmer);
> queryparser_set_stemming_strategy($query_parser, 1);
The flat function interface is deprecated. Also, use symbolic constants
rather than the numbers that happen to currently be equivalent. So
instead write:
$query_parser = new queryparser();
//set the stemmer and turn on the stemming strategy
$query_parser->set_stemmer($stemmer);
$query_parser->set_stemming_strategy(QueryParser_STEM_SOME);
> $query = queryparser_parse_query($query_parser,
> strtolower($_REQUEST["search"]) . $append);
What's $append? It's almost inevitably a mistake to attempt to
manipulate the user's input before feeding it to the QueryParser.
If you want to add filters, etc then construct a new Query object
from the Query object that the QueryParser builds.
> Anyone know what I'm messing up?
Not from the information given - everything looks plausible. Try adding
this to see what $query is:
echo $query->get_description()."\n";
If that looks OK, then use "delve" to see what terms are actually in the
database.
Cheers,
Olly
More information about the Xapian-discuss
mailing list