我将 ElasticSearch 用作我的 Post
模型的 Rails pet 项目应用程序的全文引擎。在我的 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
如果存在查询参数,他应该过滤结果并将其呈现给 index.html.erb
。
我得到的是什么
Elasticsearch::Transport::Transport::Errors::NotFound: [404] {"error":"IndexMissingException[[posts] missing]","status":404}
我运行了 bundle exec rake environment elasticsearch:import:model CLASS='Post'
但我仍然遇到同样的错误。
用 Marvin Gaye 的话来说,这是怎么回事?
最佳答案
尝试:
bundle exec rake environment elasticsearch:import:model CLASS='Post' FORCE=true
注意 FORCE=true
。
关于ruby-on-rails - Elasticsearch ::传输::传输::错误::未找到:[404],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27923176/