xapian-fu
xapian-fu copied to clipboard
Documentation on Document updating
I'm having trouble figuring out how to update a document. Could you please provide some documentation or at least comment on this issue? Thanks!
Hi @jasonlfunk,
sometimes the most obvious stuff doesn't seem obvious until someone points it out! I'm amazed the README doesn't have an example for that!
It's as simple as re-adding the document with the same id. XapianFu will see that the document already exists in the db and do a replace instead of an add.
If you're not setting your own ids, you can get the id as you add them like this:
doc = db << { :title => "Seven Psychopaths" }
doc.id
Note that it replaces the whole document, so you can't just update individual fields (unless you have them all stored and retrieve it properly first).
I might add this to the README now!
Thanks!