mercredi 8 décembre 2021

How should I write the query for ElasticSearch in Rails?

I have to write a query in my SortBuilder.rb in which I want the count of occurrence of a word (that is coming in this method in the variable value) in the results and sort the results according to the word count.

I also want to display the count later so I want to store them in a variable.

My current logic is --

   sort: [
     query: value,
     aggs:  {
       my_terms: {
         filters: {
           value: { term: { "title" => "#{value}" }}
         }
       }
     }
   ]

Aucun commentaire:

Enregistrer un commentaire