如何在Tire中设置Elastic Search的minimum_number_should_match?

时间:2012-11-28 17:24:09

标签: ruby-on-rails elasticsearch tire

我在布尔查询中设置minimum_number_should_match时遇到了一些麻烦。我想知道如何设置它。另外,默认是什么?

options = {:minimum_number_should_match => 1}

result = tire.search(load: true, page: params[:page], per_page: 20) do 
  query do 
    boolean do
      must {string squery, default_operator: "OR"} if squery.present?
      must {term :aasm_state, aasm_state }
      must {text :zipcode, zipcode} unless zipcode.nil?
      should {text :city, city} if city
      should {term :phone_store, true}
      should {term :email_store, true}
    end
  end 

  sort {by :created_at, 'desc' } if squery.blank?
end

1 个答案:

答案 0 :(得分:1)

您需要将这些选项传递给boolean方法,请参阅https://github.com/karmi/tire/issues/235#issuecomment-3846598