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

Added condition for :update after commit & rescue if record NotFound #780

Merged
merged 2 commits into from
Jul 24, 2018

Conversation

rndev15
Copy link
Contributor

@rndev15 rndev15 commented Mar 27, 2018

Hey guys
I just added readme condition for such case:
Instance of article exists, persisted, and published so successfully indexed. Then, if you make it unpublished, according to current example it will not be indexed, because

self.published? == true

I've added condition to delete document if it's non-published, and update if published. In case document was published (created), then deleted (on update hook), and then published again, __elasticsearch__.update_document will create a new document.
Second point is exception handling - when gem trying to delete non-existing document, it throws Elasticsearch::Transport::Transport::Errors::NotFound. I've just added rescue for it.

Thank you.

@karmi
Copy link
Contributor

karmi commented Apr 25, 2018

Hi @romkaspb , sorry for the long silence here! I've read through the patch and both additions do make sense, thanks! Particularly the check for NotFound is useful for somebody copy&pasting code :)

The CLA check is red, would be so kind to sign the contributor agreement? I understand this is a small change to documentation, but it just makes all the administration around code changes easier.

Also, if you'd have a bit more time, would you be able to split the commit into two? These are unrelated changes and I had to squint for a while until I have realized the patch touches two different parts of the codebase :) It's not required by any means, I can do that myself during merging, or keep it as it is.

@rndev15 rndev15 force-pushed the fix_callbacks_readme branch from 8ac0110 to ca9d51b Compare July 23, 2018 15:15
@rndev15
Copy link
Contributor Author

rndev15 commented Jul 23, 2018

Hi @karmi!
Sorry for much more long silence. I think I've missed notification somewhere in my mailbox. :)
Just signed contributor agreement and splitter PR to different commits.
Sorry for my poor english.

Thank you!

@estolfo
Copy link
Contributor

estolfo commented Jul 24, 2018

Thanks @romkaspb !

@estolfo estolfo merged commit 071fa96 into elastic:master Jul 24, 2018
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

Successfully merging this pull request may close these issues.

3 participants