[Xapian-discuss] Design-question/problem - boolean prefixes

John Leach john at johnleach.co.uk
Sun Aug 30 13:08:51 BST 2009


On Sun, 2009-08-30 at 06:25 +0100, Olly Betts wrote:
> On Fri, Aug 28, 2009 at 01:23:01PM +0100, John Leach wrote:
> > I believe that the most efficient way to do the query would actually be
> > to use the OP_FILTER query on the book id term - not sure if you can do
> > this via the query parser, so you'd have to build that yourself.
> 
> It's not so much "most efficient", as "avoiding the filter affecting the
> weights".  To do this, add "book:" as a boolean filter, and then the
> QueryParser will apply it for you using OP_FILTER - see:
> 
> http://xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html#ac4192166cf335462bbfa8f1f17a667c

Ah, I hadn't got around to understanding boolean prefixes yet, thanks
Olly!

Carsten, if this isn't clear, at index time you'd need to add the book
id term to every document with a prefix, say "XBOOKID", so the term for
book 88 would be "XBOOKID88".

Then when setting up the query parser you'd do:

qp.add_boolean_prefix("book", "XBOOKID");

which would translate a query of "book:88" back into the term XBOOKID88
(and use it as an OP_FILTER, as Olly stated).

John.

-- 
http://johnleach.co.uk
http://www.brightbox.co.uk




More information about the Xapian-discuss mailing list