Rub*_*tic 1 ruby-on-rails ruby-on-rails-3 elasticsearch tire
到目前为止,爱轮胎和弹性搜索,但无法弄清楚如何搜索范围之间的值,如:
并返回所有年龄介于这两个范围之间的个人资料?我有一个整数列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)
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)
| 归档时间: |
|
| 查看次数: |
2102 次 |
| 最近记录: |