Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception"
Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception"
不确定在使用 elasticsearch
的本地环境中工作时我遇到了这个奇怪的错误,我将不胜感激。谢谢
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})
通过 运行 这些位于 rails console
的命令索引 ES 解决了问题:-
Model.__elasticsearch__.create_index!
Model.__elasticsearch__.create_index! force: true
Model.import force: true
您也可以按照我在 rubydoc 网站上找到的步骤进行操作:
需要在您的应用程序中定义任务,例如。在 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
导入所有模型。
不确定在使用 elasticsearch
的本地环境中工作时我遇到了这个奇怪的错误,我将不胜感激。谢谢
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})
通过 运行 这些位于 rails console
的命令索引 ES 解决了问题:-
Model.__elasticsearch__.create_index!
Model.__elasticsearch__.create_index! force: true
Model.import force: true
您也可以按照我在 rubydoc 网站上找到的步骤进行操作:
需要在您的应用程序中定义任务,例如。在 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
导入所有模型。