Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on Document updating #20

Open
jasonlfunk opened this issue Apr 24, 2013 · 2 comments
Open

Documentation on Document updating #20

jasonlfunk opened this issue Apr 24, 2013 · 2 comments

Comments

@jasonlfunk
Copy link

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!

@johnl
Copy link
Owner

johnl commented Apr 24, 2013

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!

@jasonlfunk
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants