[Xapian-discuss] searching through different "fields"?

Olly Betts olly at survex.com
Fri Aug 15 02:43:56 BST 2008


On Thu, Aug 14, 2008 at 05:59:17PM +0200, Dr.BYTE at web.de wrote:
> $gen->index_text('pizza spaghetti', 1, 'X1');
> 
> After this, it should be indexed as you suggest:
> 
> X1pizza
> X1spaghetti

You should check what's actually in the index (see below).

> Searching related users by query:
> 
> $query_parser->add_prefix('user_food', 'X1');
> 
> $query = new XapianQuery($query_parser->parse_query('user_food:(spaghetti OR pizza)'));
> 
> results in:
> Parsed query is: Xapian::Query((X1spaghetti:(pos=1) OR X1pizza:(pos=2)))
> 
> This seems nice for me, but displays no results :(

There are some tips (both general and specific) for debugging such
situations here:

http://trac.xapian.org/wiki/FAQ/NoMatches

So use delve as described to see what terms have actually been indexed.

I suspect the issue may be the "1" on the end of the prefix being
handled inconsistently (the expectation is that the prefix is all
capital letters, though I don't think anything explicitly checks and
complains about anything else).  If so, setting "X1:" as the prefix for
the parser may work around this, but I've not tested that.  Using
something like "XUSERFOOD" should work though.

Cheers,
    Olly



More information about the Xapian-discuss mailing list