[Xapian-discuss] Re: Query / Database question

Ross Lawley ross.lawley at gmail.com
Tue Feb 27 11:29:13 GMT 2007


Hi all,

I'm still getting there!  I've added more indexes for things like the title
and the description, however, I'm struggling to get a function
boolean_prefix working.  I'm using dbi2omega and scriptindex to index the
content and I'm writing a custom PHP class to do the search logic.

My PHP looks something like:
<code>
$xapian_stemmer = new XapianStem("english");
$xapian_query_parser = new XapianQueryParser;
$xapian_query_parser->set_stemmer($xapian_stemmer);
$xapian_query_parser->set_stemming_strategy (0);
$xapian_query_parser->add_prefix("title", "S");
$xapian_query_parser->add_prefix("description", "XDESC");
$xapian_query_parser->add_boolean_prefix("type", "XTYPE");
$xapian_query_parser->set_database($db);
$xapian_query_parser->set_default_op(XapianQuery::OP_OR);

// Force searching of type:11
// $query = queryparser_parse_query ($xapian_query_parser, 'type:11');
$xapian_query = $xapian_query_parser->parse_query('type:11');
$xapian_enquire->set_query($xapian_query);
$xapian_matchset = $xapian_enquire->get_mset($page, $count);
</code>

My content.index looks like
<code>
id : field=id
title: index=S field=title
type: field=type_id boolean=XTYPE
description: truncate=200 index=XDESC field=content
</code>

However, with that query I never return any results - yet I know there are
items indexed with the XTYPE value of 11.  What am I missing? Or more likely
what should I be doing as well?

Also, I'm looping the search terms and expanding them so that a search for
"zulu" would become "title:zulu OR description:zulu"  Should I be doing
that, searching for just "zulu" doesn't return any results.

Also on a side note is there any way to add more weighting to results that
match the title over the description?

Once again many thanks for your help - I'm getting there just need to be
able to use the boolean correctly and I'm away!

Ross


More information about the Xapian-discuss mailing list