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

Ana*_*and 3 ruby-on-rails elasticsearch elasticsearch-rails

不确定在本地环境中工作时elasticsearch遇到这个奇怪的错误,任何帮助我都会很感激。谢谢

Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception","re​​ason":"没有这样的索引","re​​source. type":"index_or_alias","re​​source.id":"invoices","index":"invoices"}],"type":"index_not_found_exception","re​​ason":"没有这样的索引","re​​source.type" :"index_or_alias","re​​source.id":"invoices","index":"invoices"},"status":404})

Ana*_*and 5

通过在以下位置运行这些命令来索引 ES 修复了问题rails console:-

Model.__elasticsearch__.create_index!
Model.__elasticsearch__.create_index! force: true
Model.import force: true 
Run Code Online (Sandbox Code Playgroud)

  • 您所需要的只是“Model.import(force: true)” - 这将创建索引,然后进行导入 (5认同)