2017-07-16 69 views
0

我有一個Rails應用程序,它具有依賴於elasticsearch的搜索系統,我使用盆栽插件將它推到了heroku上,但是每當我嘗試搜索在我的應用程序,它給我在日誌中的這個錯誤。Elasticsearch :: Transport :: Transport :: Errors :: BadRequest error Heroku

2017-07-16T04:04:44.083489+00:00 app[web.1]: Completed 500 Internal Server Error in 18ms (ActiveRecord: 1.9ms) 
2017-07-16T04:04:44.084229+00:00 app[web.1]: app/controllers/search_controller.rb:7:in `show' 
2017-07-16T04:04:44.084222+00:00 app[web.1]: Elasticsearch::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"no [query] registered for [filtered]","line":1,"col":22}],"type":"parsing_exception","reason":"no [query] registered for [filtered]","line":1,"col":22},"status":400}): 

我Elasticsearch控制器

class SearchController < ApplicationController 
    before_action :beautify_url 
    layout "simple" 

    def show 
    @post_records = Post.search(query_term).paginate(page: params[:page]).records 
    @posts = @post_records.to_a.select { |post| post.published? } 
    @users = User.search(query_term).records.to_a 
    @tags = Tag.search(query_term).records 
    end 

    def users 
    @users = User.search(query_term).records.to_a 
    end 

    private 

    def beautify_url 
     if params[:search].present? 
     case params[:action] 
     when "show" 
      redirect_to search_url(q: params[:search][:q]) 
     when "users" 
      redirect_to search_users_url(q: params[:search][:q]) 
     end 
     end 
    end 

    def query_term 
     params[:q] || '' 
    end 
end 

請幫助!

回答

1

盆景支持在這裏。盆景簇目前正在供應上Elasticsearch 5.x的,並且作爲Elasticsearch 5.0的,所述filtered查詢已被刪除。試圖在5.x中使用filtered查詢會導致您看到的錯誤消息。

從你分享的內容來看,最可能的問題是客戶端正在使用查詢DSL的已棄用版本。這將表明一個不兼容的寶石版本。

您可以檢查Elasticsearch寶石是什麼版本通過在命令行中運行以下命令:

bundle show | grep elasticsearch

如果它們不5.xx的,在你的Gemfile更新它們:

gem "elasticsearch", "~> 5" 
gem "elasticsearch-rails", "~> 5" 

並運行bundle update elasticsearch elasticsearch-rails。將更改推送到Heroku並再次嘗試搜索。

如果這沒有幫助,請發郵件到[email protected],我們會幫您解決。

+0

我已經更新了我的gemfile @Rob Sears,但問題依舊 –

相關問題