I have set everything up using ElasticSearch and SearchKick, however, I cannot get it to work quite like I want to. I need to have multiple searches.
My model, Car, has two attributes such as "Make" and "Year". I can do this:
Car.search( query: { match: {make: { query: "toyota" } }} )
How do I also find matches that belong to Toyoto but also belonging to a specific year, say 2012.
Thank you
假设该年份是您的Car模型的属性或在您的search_data配置中明确定义,这应该工作:
Car.search "toyota", where: { year: 2012 }
This will returns cars in which make is "toyota" AND year is 2012
Car.search "*", where: { make: 'toyota', year: 2012 }
For make is "toyota" OR year is 2012
Car.search "*", where: { or: [[{make: 'toyota'},{year: 2012}]] }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.