Skip to main content

ElasticSearch 400 error.

Rails • Asked by Sillico

Hello!

I am pretty new to Rails and recently signed up to try to get some more exposure. I have been playing around with Elastic Search, but am having a hard time implementing some of the more advanced features. I watched the episode on GoRails, but when I try to boot up the server from the GoRails repo, I constantly get 400 errors. I tried searching my project directory for "fields" an found one result that I replace with stored_fields. Then I tried commenting out that function. However, nothing changes. What am I missing / doing wrong?

Searchkick::InvalidQueryError in QuestionsController#index
[400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"The field [fields] is no longer supported, please use [stored_fields] to retrieve stored fields or _source filtering if the field is not stored","line":1,"col":127}],"type":"parsing_exception","reason":"The field [fields] is no longer supported, please use [stored_fields] to retrieve stored fields or _source filtering if the field is not stored","line":1,"col":127},"status":400}

 def index
    query = params[:q].presence || "*"
    @questions = Question.search(query, suggest: true) # The highlighted line from the error page on rails server
  end

  # GET /questions/1

I believe this is an error is relating to a version of elasticsearch and Searchkick.

Can you check what version of elasticsearch you're running and what version of the searchkick gem you have in you Gemfile/Gemfile.lock?


I actually ended up watching the video and using parts of the video with what I had already built out to get the desired result. Great tutorial though!


I'm actually seeing the same error in a controller spec. Searchkick v. 1.3.2, elasticsearch v. 2.0.0. Rails 4.2.6 & Ruby 2.2.2. I didn't set up this searchkick so I've been googling around for suggestions on the issue and this is one of few instances of the same error.


Edit: Figured it out! Elasticsearch 5+ (not the gem) renames fields to stored_fields, and searchkick doesn't support that in 1.3.2. I updated searchkick and it's all fine.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.