[Xapian-discuss] QueryParser,
mapping a single prefix to multiple fields ?
Daniel Ménard
Daniel.Menard at Bdsp.tm.fr
Wed Sep 13 11:34:51 BST 2006
Hello,
The doc for QueryParser::add_prefix and QueryParser::add_boolean_prefix
says that "multiple fields can be mapped to the same prefix", which is
very convenient to handle aliases.
But I am in the opposite situation where I would like to map a same
prefix to multiple fields: for example, a search for 'title:xapian'
would look for 'XTITLEFRExapian' or 'XTITLEENGxapian'.
What would be the best way to achieve this? (I'm using the PHP bindings)
From what I see, this is not something which is currently supported. If
I call multiple times add_boolean_prefix with the same 'field', only the
first prefix is taken into account.
A solution would be to 'duplicate' search terms, adding a prefix like
'XTITLE ENG AND FRE', but this is obviously a waste of resources.
For now, the only solution I see is to pre-process the user request
before giving it to the query parser (replace "title:something" with
"titleeng:something OR titlefre:something" for each field I want to
handle like this)... which is not very elegant.
Perhaps it would be a useful feature to add to the query parser? It
would not break the API (just call add_prefix / add_boolean_prefix
several times with the same field and different prefixes) and I don't
think it would break any existing code.
Of course ;-) , I'm not fluent enough in C++ to code that myself, and I
don't even know if I ask for a simple change or a big one!
Please let me know...
Best regards,
Daniel
More information about the Xapian-discuss
mailing list