Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add index_on_update! option #153

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

Closed
barelyknown wants to merge 1 commit into elastic:master from barelyknown:index-on-update

Conversation

@barelyknown
Copy link
Contributor

@barelyknown barelyknown commented Jun 24, 2014

I needed to always index on update for some ActiveRecord classes. This provides an index_on_update! method to set that behavior for a class. I did not add tests for it yet but could.

Copy link
Contributor

karmi commented Jun 25, 2014

Hey, this feels like a bandaid for the problems with update_document not picking up the "correct" JSON serialization of the model -- many issues are opened for that... I absolutely do think that something can be improved here, but preferably on a different level than a magical class level method? Some other way of configuration, different kind of introspection we do, etc...

Copy link
Contributor Author

I agree that there is probably a better way. In the project that I'm working on I would always want to call index_document on update and never update_document because there is content that is fetched from an external service that ActiveModel::Dirty doesn't know anything about. So, while it sounds important to improve update_document, it would never be right for me in this case. What do you think would be the "right" way specify that the indexing method that should be used on update?

Copy link
Contributor

karmi commented Jun 25, 2014

Hmm, if that is the case, why not simply implement the after_save etc. hooks yourself, as documented in https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-model/README.md#custom-callbacks? (The "automatic callbacks" are really just a starting point,a default.)

Copy link
Contributor Author

Yeah. You're totally right. I had been thinking that the callbacks were more tied than they are to Elasticsearch::Model. I'm not sure why since I had read the code! Tired eyes 😴 😴 😴

Copy link
Contributor

karmi commented Jun 25, 2014

I can totally understand that, what worries me that despite all the effort in the README to state that it's just a "starting point", people try to augment/customize/etc the default callbacks, instead of writing the three lines of Ruby to solve a problem cleanly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /