[英]Tire + Elasticsearch: How to search ranges of values?
Love Tire and elasticsearch so far but can't figure out how to search values between ranges like: 到目前为止,您一直很喜欢Tyre和elasticsearch,但无法弄清楚如何在以下范围之间搜索值:
And return all Profile's where the age is between these 2 ranges? 并返回年龄在这两个范围之间的所有配置文件? I have a integer column Profile.age 我有一个整数列Profile.age
So far incomplete function 到目前为止功能不完整
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
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.