Multiple Search Queries Using Ruby Searchkick

I installed everything using ElasticSearch and SearchKick, however I cannot get it to work the way I want. I need to have some queries.

My model, a car, has two attributes, such as "Make" and "Year." I can do it:

Car.search( query: { match: {make: { query: "toyota" } }} )

How to find matches that belong to Toyoto, but also related to a particular year, say, 2012.

thanks

+4
source share
2 answers

Assuming this year is either an attribute of your car model or explicitly specified in your search_data configuration file, this should work:

Car.search "toyota", where: { year: 2012 }
+2
source

, make "toyota" 2012

Car.search "*", where: { make: 'toyota', year: 2012 }

make "toyota" 2012

Car.search "*", where: { or: [[{make: 'toyota'},{year: 2012}]] }
0

Source: https://habr.com/ru/post/1526842/


All Articles