简体   繁体   中英

Elasticsearch::Transport::Transport::Errors::NotFound ([404] {“error”:{“root_cause”:[{“type”:“index_not_found_exception”

Not sure while working in local environment with elasticsearch im 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})

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 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM