[Xapian-discuss] searching on individual fields

James Aylett james-xapian at tartarus.org
Sun Jun 22 03:19:08 BST 2008


On Fri, Jun 20, 2008 at 03:22:32PM +0200, james cauwelier wrote:

> I am using xapian to search a products database of a website (currently 382
> 000 products).  I am able to build an index and query it.  I was also able
> to index separate fields, but I can't find how to combine different parsed
> query strings in PHP:
> 
> // construct query
> $fields = array ('title', 'publisher', 'category', 'subcategory',
> 'subsubcategory');
> $query = array();
> foreach ($fields as $field_name) {
>     $parser = new XapianQueryParser ();
>     $parser->set_stemmer ($stemmer);
>     $parser->set_database ($database);
>     $parser->set_stemming_strategy (XapianQueryParser::STEM_ALL, null,
> 'X'.strtoupper($field_name));
>     $query[] = '('.$parser->parse_query ($form[$field_name], null,
> 'X'.strtoupper($field_name)).')';
> }
> $query = implode (' AND ', $query);
> 
> I have different fields which have each a label, for example XTITLE for the
> field 'title'.  I use $parser->set_stemming_strategy() to use the correct
> labels for these fields, but I seem to make a mistake with the second
> argument for this function.  How do I set this FLAG in PHP?  Can I set
> multiple?  Do I have to set a flag?  Can I set all flags?
> I looked at the API, but I don't seem to find the answer.

You shouldn't try to configure prefixes using flags and
set_stemming_strategy(); instead, use
add_prefix(prefix_in_query_string, prefix_in_database):
<http://tinyurl.com/6c87fs>.

(I believe there is no second argument for set_stemming_strategy(); if
the error message you get isn't clear that this is the problem, then
please let us know.)

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list