elasticsearch-rails: Elasticsearch::Transport::Transport::Errors::NotFound on `object.destroy()`

I’ve got a very simple, vanilla ES setup using the feature extraction pattern, with no custom callbacks or anything like that – see my other issue for details. I’m getting the following error consistently every time I try to destroy an ES-enabled model:

Elasticsearch::Transport::Transport::Errors::NotFound: [404] {"found":false,"_index":"surveys","_type":"survey","_id":"60","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}

Obviously, this one occurs when I run Survey.find(60).destroy(). Survey has_many Questions which are marked dependent: destroy; the Questions appear to be deleted without issue, and then this error gets raised on the call DELETE FROM "surveys" WHERE "surveys"."id" = ? [["id", 60]]. The call does actually succeed in deleting the survey before the error is raised.

Any idea what might cause this issue?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

I was also getting the same error on my rails console whenever i was calling destroy method on ES-enabled model. But it vanished when i replaced automatic callbacks by custom callbacks. I removed “include Elasticsearch::Model::Callbacks” and included custom callbacks:

after_commit on: [:create] do
  __elasticsearch__.index_document
end

after_commit on: [:update] do
  __elasticsearch__.index_document
end

after_commit on: [:destroy] do
  __elasticsearch__.delete_document
end 

It seems that issue lies in automatic callback.

I’ve got the same issue.

Thanks for your answers. I finally solved my issue creating index. My problem was with heroku and elasticsearch. The solution is install gems elasticsearch rails / model, and for bonsai heroku gem elasticsearch-bonsai. After run in rails index create for corresponding class.

@soujanya24, I’m sorry, but you would have to provide full details about your environment, the versions of the Rubygem and Elasticsearch used, preferably in a new issue, so we’re able to help you. Posting a question like this isn’t helpful at all.

@sechix Sidekiq should be restarted when you do some changes in worker class.

The same issue here, appearing randomly, together with too many connection resets (due to closed stream - IOError) after 0 requests on 70235882588320, last used 1471107194.7592144 seconds ago and sometimes succeeding.

There is no guide or help anywhere on the web to resolve this issue. Makes elasticsearch unusable, there is no workaround.

Elasticsearch running on localhost:9200.