简体   繁体   中英

How can I set up Elastic Search's minimum_number_should_match within Tire?

I'm having a bit of trouble setting the minimum_number_should_match within my boolean query. I'm wondering how I can set that. Also, what is the default?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM