-
Notifications
You must be signed in to change notification settings - Fork 792
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
Incomplete index in Callback #5
Comments
Hi, thanks! Can you clarify the issue a bit, please? The thing is, that -- contrary to Tire --, So, are you saying that some of these changes are not correctly intercepted? Would it be feasible to model it in the integration test? |
Thanks!
But some class User << ActiveRecord::Base
def as_indexed_json(options={})
{ :id => id,
first_name: first_name,
last_name: last_name,
full_name: "#{first_name} #{last_name}",
}
end
end So, to avoid more problems, I think is better invoke Hope you can understand my poor English. |
Aaah, now I know what you mean --
Yeah, but that would defeat the purpose of the partial update I guess :) I'll have to revisit this part... |
Exactly! But I think the partial update should be based on |
Unless I'm mistaken, that wouldn't help, since the |
Thanks, Temporary using this to fix it : after_update -> {
__elasticsearch__.index_document
} |
Should I reopen this issue for tracking? |
I still haven't found a way how to solve this acceptably, please see my comments above. Unless there some kind of support for "computed" or "dependent" model attributes (a la e.g. Ember.js), these derived attributes simply are not reachable by I can see an argument that as soon as you define |
So, for the record, the trouble with your use case is that If it were a "read-only", or "computed" attribute, such as: class Person < ActiveRecord::Base
def full_name
[first_name, last_name].compact.join(' ')
end
end which would be used in So, in my opinion, the library behaves absolutely predictably here. |
Now I know what to do, thank you! |
…serialized during update Previously, the `update_document` method simply intercepted the changes to the model, via the `@__changed_attributes` variable, and used these directly. This caused models with a custom serialization method to be incorrectly serialized, namely unwanted attributes were added. This patch looks for `as_indexed_json` defined on the model, and when it finds it, filters the changed attributes through the keys. Closes #75 Related: * #59 * #57 * #52 * #40 * #37 * #5
@samqiu Please see the linked commit, it should solve one variant of the bug you have hit. I'm afraid, though, that your specific case, ie. having a custom method, which is then used in the Let me repeat once more that the "automatic callbacks" were always meant as a convenience -- for most complex cases, you need to define them, preferably via Sidekiq/etc... |
Thank you. I will going to use Sidekiq for indexing. |
Hi @karmi ,
Thank you for your awesome gems!
I am replacing
Tire
toelasticsearch-rails
, the first issue is that it won't performas_indexed_json
whenupdate_document
, It' s updatechanged_attributes
only.Is there any solution about this? perform
as_indexed_json
whenupdate_document
, not onlychanged_attributes
.Source
https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-model/lib/elasticsearch/model/indexing.rb#L334
Model
The text was updated successfully, but these errors were encountered: