[英]Elasticsearch::Transport::Transport::Errors::NotFound: [404]
I'm using ElasticSearch as full text engine for my rails pet project app for my Post
model. 我正在使用ElasticSearch作为我的
Post
模型的rails pet项目应用程序的全文引擎。 In my posts_controller.rb
index action: 在我的
posts_controller.rb
索引操作中:
def index
if params[:query]
@posts = Post.search(params[:query]).page(params[:page]).records
else
@posts = Post.paginate(page: params[:page]).order('created_at DESC')
end
end
Where, if a query param is present he should filter the results and present it to the index.html.erb
. 其中,如果存在查询参数,则应过滤结果并将其呈现给
index.html.erb
。
What happens is I get 我得到的是什么
Elasticsearch::Transport::Transport::Errors::NotFound: [404] {"error":"IndexMissingException[[posts] missing]","status":404}
I ran the bundle exec rake environment elasticsearch:import:model CLASS='Post'
but I still get the same error. 我运行
bundle exec rake environment elasticsearch:import:model CLASS='Post'
但我仍然得到相同的错误。
In the words of Marvin Gaye, What's going on? 用Marvin Gaye的话说,发生了什么?
Try: 尝试:
bundle exec rake environment elasticsearch:import:model CLASS='Post' FORCE=true
Note FORCE=true
. 注意
FORCE=true
。
This Error came for me as well, and i resolved it through following, 这个错误也出现了,我通过以下方式解决了这个问题,
go to Rails Console - CTRL , and then create index at your MODEL, 转到Rails控制台 - CTRL,然后在你的MODEL上创建索引,
MODEL_NAME.import force: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.