3

不确定在本地环境中工作时elasticsearch遇到这个奇怪的错误,我将不胜感激。谢谢

Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception","re​​ason":"no such index","re​​source. type":"index_or_alias","re​​source.id":"invoices","index":"invoices"}],"type":"index_not_found_exception","re​​ason":"no such index","re​​source.type" :"index_or_alias","re​​source.id":"invoices","index":"invoices"},"status":404})

4

2 回答 2

7

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

Model.__elasticsearch__.create_index!
Model.__elasticsearch__.create_index! force: true
Model.import force: true 
于 2018-04-17T05:13:30.607 回答
0

您也可以按照我在ruby​​doc网站上找到的以下步骤操作:

需要在您的应用程序中定义任务,例如。在 lib/tasks/elasticsearch.rake 文件中:

require 'elasticsearch/rails/tasks/import'

要从您的模型中导入记录,请运行:

bundle exec rake environment elasticsearch:import:model CLASS='ModelName'

或者您可以使用:

rake environment elasticsearch:import:all DIR=app/models

导入所有模型。

于 2018-08-01T11:39:46.480 回答