gpt4 book ai didi

ruby-on-rails - Elasticsearch::运输::运输::错误::BadRequest错误heroku

转载 作者:行者123 更新时间:2023-12-03 00:55:22 27 4
gpt4 key购买 nike

我有一个Rails应用程序,它的搜索系统取决于elasticsearch,我已经使用盆景插件将其推到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 Controller
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

请帮忙!!

最佳答案

盆景支持在这里。当前在Elasticsearch 5.x上配置了盆景集群,并且从Elasticsearch 5.0开始,filtered查询已被删除。尝试在5.x中使用filtered查询会导致您看到该错误消息。

从您共享的内容来看,我想说的最可能的问题是客户端正在使用不建议使用的Query DSL版本。那将暗示一个不兼容的gem版本。

您可以通过在命令行中运行它来检查Elasticsearch gems的版本:
bundle show | grep elasticsearch
如果它们不是5.x.x,请在您的Gemfile中更新它们:

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

并运行 bundle update elasticsearch elasticsearch-rails。将更改推送到Heroku,然后再次尝试搜索。

如果仍然不能解决问题,请发送电子邮件至support@bonsai.io,我们将帮助您解决问题。

关于ruby-on-rails - Elasticsearch::运输::运输::错误::BadRequest错误heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45125207/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com