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
update document should update with hash from as_indexed_json. #182
Conversation
+1 |
Well, #166 solves the problem of not using as_indexed_json to update the index. However, it is still limited to the attribute keys returned by changed_attriubtes which only watches changes in field attributes. If a custom key value (some derived value) is added within as_indexed_json, that key value change is not being watched. Hence if there's a change in that value, the change is not reflected in the index. Therefore my solution deletes the unchanged key-values instead of selecting the changed key-values. This will insure that any custom key value pair will be included in the update. This was my issue in #178. |
Can this be merged? The build failures appear to be spurious. |
Any update on this? |
Hate to just +1 an issue, but this is the same problem I'm having as well and a little lost. Are there any work-arounds in the meantime for "forcing" a derived field to get sent along with ES updates? |
Okay dug around in this more today and personally I like the @dwkoogt solution.
In my opinion this is a pretty significant and sneaky bug that should be fixed. @karmi "It certainly cannot be merged as is... We can absolutely have talk about the problem there." Could you let us know what needs to be improved here to have it merged? I'd be willing to spend some time on this. |
…uld also contain derived attributes.
…selected for specific changed attribute.
d0ab82d
to
5cc68b5
Compare
Hi @karmi, just updated my profile with the email address. thx. |
@@ -393,7 +393,9 @@ def delete_document(options={}) | |||
def update_document(options={}) | |||
if changed_attributes = self.instance_variable_get(:@__changed_attributes) | |||
attributes = if respond_to?(:as_indexed_json) | |||
self.as_indexed_json.select { |k,v| changed_attributes.keys.map(&:to_s).include? k.to_s } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change for performance? Original version seemed more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original change included with_indifferent_access method which is a rails extension which I removed here.
Btw, I rebased on master and Travis is failing on this: |
@karmi any updates on what needs to happen here? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
update document should update with hash from as_indexed_json which could also contain derived attributes.
resolves #178
this also should resolve issues #88 #166 and #195