Using elasticsearch and Tire im trying to search a few profile records.
Try to get results where gender = male and age_from = 18, age_to = 30. Currently with this setup it returns everyone that is inside this age range even woman. How Can i make it behave to only return the males in this age range?
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
Use must instead of should. It should work.