[Xapian-discuss] Resume indexing

Olly Betts olly at survex.com
Tue Oct 5 07:24:46 BST 2010


On Tue, Oct 05, 2010 at 05:59:48AM +0100, Olly Betts wrote:
> Otherwise (or alternately) you can use transactions and make a note
> where you've got up to after each transaction is successfully committed.

Oh, and a neat way to eliminate the race between the transaction getting
committed, and you recording the fact, is to note where you got up to using
the Xapian database's user metadata (which gets committed, or not, along
with the rest of the transaction):

    db.begin_transaction()
    string up_to = db.get_metadata("up_to");
    // Add a batch of documents - if up_to is empty, start from the beginning,
    // otherwise resume from the point identified by up_to, and return a string
    // identifying the new point we've indexed up to.
    up_to = add_some_documents(db, up_to);
    db.set_metadata("up_to", up_to);
    db.commit_transaction();

Cheers,
    Olly



More information about the Xapian-discuss mailing list