Skip to content

Conversation

@barelyknown
Copy link
Contributor

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.

@karmi
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...

@karmi karmi added the waiting label Jun 25, 2014
@barelyknown
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?

@karmi
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.)

@barelyknown
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 😴 😴 😴

@karmi
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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants