I'm using ElasticSearch as full text engine for my rails pet project app for my Post
model. In my posts_controller.rb
index action:
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
.
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.
In the words of Marvin Gaye, What's going on?
Try:
bundle exec rake environment elasticsearch:import:model CLASS='Post' FORCE=true
Note 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,
MODEL_NAME.import force: true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.