[Xapian-discuss] Design-question/problem

John Leach john at johnleach.co.uk
Fri Aug 28 13:23:01 BST 2009


On Fri, 2009-08-28 at 13:59 +0200, Carsten Reimer wrote:

> we are using the Xapian-python bindings to build some fulltext search 
> engine for some 400+ books each about 300+ pages.
> 
> We have the need to be able to limit the search on one book or on 
> several selected books as well as to be able to search all of them.

> Any ideas, hints, whatever are warmly welcome.

Hi Carsten,

one database for all books is likely the way to go.  A quick solution
would be to ensure a unique id is added as a token for each book.  When
you want to confine a search to one book, ensure that token is included
in the search.

Quick example, if each book has a unique id of the form "book88", then
the search could look like:

"book88 AND (quick brown fox)"

or perhaps: "+book88 quick brown fox"


I'd probably personally do this with term prefixes, but that takes a bit
more work to setup - it does makes sure that books that happen to have
the term book88 in it somewhere don't turn up in the search :)  With
term prefixes the search might look something like this:

"+book_id:88 quick brown fox"


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.

Hope this is useful,

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




More information about the Xapian-discuss mailing list