使用弹性搜索和轮胎即时尝试搜索一些个人资料记录。
尝试获得性别 = 男性和年龄从 = 18,年龄到 = 30 的结果。目前使用此设置,它会返回此年龄范围内的每个人,甚至是女性。我怎样才能让它表现得只返回这个年龄段的男性?
if params['people']
tire.search(load: true, page: params[:page], per_page: 50, :default_operator => 'AND', :use_dis_max => true) do
query do
boolean do
should { range :age, {gte: params['people'][:age_from], lte: params['people'][:age_to]} }
should { string 'gender:male' } if params['people'][:gender] == "male"
should { string 'gender:female' } if params['people'][:gender] == "female"
end
end
to_curl
end
end