elasticsearch,tire,Ruby On Rails,Ruby On Rails 4,elasticsearch,Tire" /> elasticsearch,tire,Ruby On Rails,Ruby On Rails 4,elasticsearch,Tire" />

Ruby on rails 轮胎返回空阵列

Ruby on rails 轮胎返回空阵列,ruby-on-rails,ruby-on-rails-4,elasticsearch,tire,Ruby On Rails,Ruby On Rails 4,elasticsearch,Tire,我正在使用elasticsearch来加快搜索速度,但不幸的是,我不知道它返回空结果数组的原因。期待你们的帮助 class Post < ActiveRecord::Base include Tire::Model::Search include Tire::Model::Callbacks has_many :attachments, as: :attachable accepts_nested_attributes_for :attachments,

我正在使用elasticsearch来加快搜索速度,但不幸的是,我不知道它返回空结果数组的原因。期待你们的帮助

class Post < ActiveRecord::Base
    include Tire::Model::Search
    include Tire::Model::Callbacks

    has_many :attachments, as: :attachable
    accepts_nested_attributes_for :attachments, allow_destroy: true

    mapping do
        indexes :work_type
        indexes :title
        indexes :location
        indexes :industry_type
        indexes :key_words
        indexes :type       
    end

    after_save { update_index }

    def self.search(params)
        tire.search(load: true) do
            query do
                boolean do
                    must   { string                              params[:query] }         if params[:query].present?
                    must   { match :type,          params[:type] }          if params[:type].present? && params[:type] != "all"
                    must   { match :title,         params[:title] }         if params[:title].present?
                    must   { match :industry_type, params[:industry_type] } if params[:industry_type].present?
                    must   { match :key_words,     params[:key_words] }     if params[:key_words].present?
                end
            end

            sort { by :title, 'desc' }
        end
    end


params = {"utf8"=>"✓",
 "type"=>"Job",
 "query"=>"",
 "location"=>"",
 "post"=>{"work_type"=>""},
 "action"=>"index",
 "controller"=>"posts"}
class Post“✓",
“类型”=>“作业”,
“查询”=>“”,
“位置”=>“”,
“post”=>{“工作类型”=>“”},
“操作”=>“索引”,
“控制器”=>“发布”}

在这种情况下,我要做的第一件事就是让tire的记录器进入调试模式,以查看elasticsearch请求/响应json数据。