[Xapian-discuss] Mutliple boolean tags per document

Richard Boulton richard at tartarus.org
Mon Nov 7 17:43:33 GMT 2011


On 7 November 2011 17:35, Justin Finkelstein <justin at redwiredesign.com> wrote:
> Hi guys
>
> I'm about to write something for my search service which updates a
> number of documents by adding a boolean tag to a series of documents.
> Is there an efficient way where I can do "only add this tag if it isn't
> set already"?

I think the following will be pretty efficient:

 - fetch each document
 - call Document.add_boolean_term(tag_term)
 - use Database.replace_document() to put the modified document back
in the database.

The current disk backends (ie, chert, and for that matter, also flint)
load the Document contents lazily, and do minimal updating work when
writing modified documents back.  So, the above won't access the
document data and value tables at all, and will only modify the
posting list table for the tag_term (not for all the other terms in
the document).

I think it will currently read the termlist for the document; that
could theoretically be avoided in this case, I think, but isn't
currently.

-- 
Richard



More information about the Xapian-discuss mailing list