xapian-fu icon indicating copy to clipboard operation
xapian-fu copied to clipboard

Documentation on Document updating

Open jasonlfunk opened this issue 12 years ago • 2 comments

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!

jasonlfunk avatar Apr 24 '13 20:04 jasonlfunk

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!

johnl avatar Apr 24 '13 21:04 johnl

Thanks!

jasonlfunk avatar Apr 24 '13 21:04 jasonlfunk