2
我使用ElasticSearch作爲我的導軌寵物項目應用程序的全文引擎,用於我的Post
模型。在我posts_controller.rb
index動作:Elasticsearch ::運輸::運輸::錯誤::未找到:[404]
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'
但我仍然得到同樣的錯誤。
用馬文·蓋伊的話說,這是怎麼回事?
導入任務應該爲模型創建索引(如果它不存在),還是假定它存在? –
即使我之前創建了一個索引,它也會創建一個索引 – tvieira
您是否確認(使用'curl'或類似elasticsearch-head的工具)「posts'索引存在? –