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

James Aylett james-xapian at tartarus.org
Thu Aug 14 14:58:19 BST 2008


Please keep replies on-list so that others can help you, and benefit
from the replies.

On Thu, Aug 14, 2008 at 03:42:38PM +0200, Sven Kummer wrote:

> i tried out to add terms:
> $doc->add_term('X1spaghetti pizza');
> $doc->add_term('X2cars party friends');

You're adding two terms there where you actually want to add
five. Ignoring stemming, you want:

X1spaghetti
X1pizza
X2cars
X2party
X2friends

Possibly the easiest way of generating terms is to use the
TermGenerator. The introductory docs are a little difficult to read as
they are mostly documenting the changes from previous versions, but
the API docs should help.

> $query_parser->add_prefix('user_food', 'X1');
> $query_parser->add_prefix('user_interessts', 'X2');
> 
> $query_parser->parse_query('user_interessts:(party OR friends)');
> 
> but i get no results. query description writes:
> 
> Parsed query is: Xapian::Query((ZX1spaghetti:(pos=1) OR ZX1pizza:(pos=2)))

Well, it won't be that, it'll be (ZX2party:(pos=1) OR
ZX2friends:(pos=2)) or something very similar. If you construct terms
as above, you'll be fine.

J

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



More information about the Xapian-discuss mailing list