{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/721","repository_url":"https://api.github.com/repos/elastic/elasticsearch-rails","labels_url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/721/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/721/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/721/events","html_url":"https://github.com/elastic/elasticsearch-rails/issues/721","id":236165744,"node_id":"MDU6SXNzdWUyMzYxNjU3NDQ=","number":721,"title":"Updating `as_indexed_json` on after commit update callback","user":{"login":"henrikholm89","id":8633869,"node_id":"MDQ6VXNlcjg2MzM4Njk=","avatar_url":"https://avatars0.githubusercontent.com/u/8633869?v=4","gravatar_id":"","url":"https://api.github.com/users/henrikholm89","html_url":"https://github.com/henrikholm89","followers_url":"https://api.github.com/users/henrikholm89/followers","following_url":"https://api.github.com/users/henrikholm89/following{/other_user}","gists_url":"https://api.github.com/users/henrikholm89/gists{/gist_id}","starred_url":"https://api.github.com/users/henrikholm89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henrikholm89/subscriptions","organizations_url":"https://api.github.com/users/henrikholm89/orgs","repos_url":"https://api.github.com/users/henrikholm89/repos","events_url":"https://api.github.com/users/henrikholm89/events{/privacy}","received_events_url":"https://api.github.com/users/henrikholm89/received_events","type":"User","site_admin":false},"labels":[{"id":971417797,"node_id":"MDU6TGFiZWw5NzE0MTc3OTc=","url":"https://api.github.com/repos/elastic/elasticsearch-rails/labels/waiting-for-user","name":"waiting-for-user","color":"e59d77","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-06-15T11:57:20Z","updated_at":"2018-08-13T17:29:05Z","closed_at":null,"author_association":"NONE","body":"I am not sure if it is a bug or intentional. \r\n\r\nHowever, whenever `__elasticsearch__.update_document` gets triggered, it makes the following call to elasticsearch: `http://localhost:9200/development_users/user/8064/_update`\r\n\r\nAnd this does not seen to trigger the `as_indexed_json` method? \r\nAt least, the following methods on my model/document is not getting updated:\r\n\r\n```\r\n  def as_indexed_json(*)\r\n      as_json(\r\n        methods: [:primary_team, :club, :top_player?]\r\n      )\r\n    end\r\n```\r\n\r\nHowever, when I call the `__elasticsearch__.update_document` directly on the model in a rails console, it for some reasons triggers an `http://localhost:9200/development_users/user/8064/`, and this way it gets properly updated. But that looks like an `__elasticsearch__.index_document` http call? \r\n\r\nIs there something I'm missing here?"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/comments/412598697","html_url":"https://github.com/elastic/elasticsearch-rails/issues/721#issuecomment-412598697","issue_url":"https://api.github.com/repos/elastic/elasticsearch-rails/issues/721","id":412598697,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjU5ODY5Nw==","user":{"login":"adamcrown","id":277306,"node_id":"MDQ6VXNlcjI3NzMwNg==","avatar_url":"https://avatars3.githubusercontent.com/u/277306?v=4","gravatar_id":"","url":"https://api.github.com/users/adamcrown","html_url":"https://github.com/adamcrown","followers_url":"https://api.github.com/users/adamcrown/followers","following_url":"https://api.github.com/users/adamcrown/following{/other_user}","gists_url":"https://api.github.com/users/adamcrown/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcrown/subscriptions","organizations_url":"https://api.github.com/users/adamcrown/orgs","repos_url":"https://api.github.com/users/adamcrown/repos","events_url":"https://api.github.com/users/adamcrown/events{/privacy}","received_events_url":"https://api.github.com/users/adamcrown/received_events","type":"User","site_admin":false},"created_at":"2018-08-13T17:29:05Z","updated_at":"2018-08-13T17:29:05Z","author_association":"NONE","body":"I am having the same issue and can confirm that the following code works for me, while `Elasticsearch::Model::Callbacks` does not.\r\n```ruby\r\n  after_commit lambda { __elasticsearch__.index_document  },  on: [:create, :update]\r\n  after_commit lambda { __elasticsearch__.delete_document },  on: :destroy\r\n```\r\n\r\nIn my case it seems like updates to regular number fields are fine. But updates to `enums` are ignored."}}
{"actor":{"display_login":"adamcrown"}}