Justin Finkelstein
2011-Nov-07 17:35 UTC
[Xapian-discuss] Mutliple boolean tags per document
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"? Thanks, Justin -- Redwire Design Limited 54 Maltings Place 169 Tower Bridge Road London SE1 3LJ www.redwiredesign.com [ 020 7403 1444 ] - voice [ 020 7378 8711 ] - fax [ 07968 180 720 ] - mobile
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