轮胎+弹性搜索:如何搜索值范围?

Rub*_*tic 1 ruby-on-rails ruby-on-rails-3 elasticsearch tire

到目前为止,爱轮胎和弹性搜索,但无法弄清楚如何搜索范围之间的值,如:

  • age_from age_to
  • 18至20岁

并返回所有年龄介于这两个范围之间的个人资料?我有一个整数列Profile.age

到目前为止功能不全

def self.search(params)

    #, default_operator: "AND
    tire.search(load: true, page: params[:page], per_page: 20) do
      query do
        should { string params[:query] } if params[:query].present?
        should { integer age_to[:age_to] } if params[:age_to].present?
      end
      to_curl
    end

  end
Run Code Online (Sandbox Code Playgroud)

Rob*_*bin 6

query do
    should { string params[:query] } if params[:query].present?
    should { range :age, { gte: params[:age_from], lte: params[:age_to] } } if params[:age_to].present? && params[:age_from].present?
end
Run Code Online (Sandbox Code Playgroud)