Replace filered query with bool/must query


(Karoline Brynildsen) #1

Hi!
This is my existing query (used with ES 1.7).

{
   "query":{
      "filtered":{
         "query":{
            "function_score":{
               "functions":[
                  ...
               ],
               "query":{
                  "bool":{
                     "should":[
                        ...
                     ]
                  }
               },
               "filter":{
                  ...
               }
            }
         }
      }
   }
}

I have now upgraded to ES 5.4, and this query no longer works due to the fact that filtered queries are removed from ES 5. I understand that you should use a bool/must query instead, but I cannot figure out how to rewrite my query to fit this change. Any suggestions?


(David Pilato) #2

You should be able to write something like:

{
  "query": {
    "bool": {
      "must": [
        {
          "function_score": {
            "functions": [ ... ],
            "query": {
              "bool": {
                "should": [ ... ]
              }
            }
          }
        }
      ],
      "filter": {
        ... 
      }
    }
  }
}


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.