Reputation: 6531
Not sure while working in local environment with elasticsearch
i m getting this weird error, any help would me appreciated. thanks
Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"invoices","index":"invoices"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"invoices","index":"invoices"},"status":404})
Upvotes: 7
Views: 10318
Reputation: 1721
You can also follow this steps i find on rubydoc website :
require the task definition in your application, eg. in the lib/tasks/elasticsearch.rake file:
require 'elasticsearch/rails/tasks/import'
To import the records from your model, run:
bundle exec rake environment elasticsearch:import:model CLASS='ModelName'
Or you can use:
rake environment elasticsearch:import:all DIR=app/models
to import all models.
Upvotes: 0
Reputation: 6531
Fixed issue by indexing ES by running these commands at rails console
: -
Model.__elasticsearch__.create_index!
Model.__elasticsearch__.create_index! force: true
Model.import force: true
Upvotes: 14