Help optimize my query

I have this query:

"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"range": {
"movies-date": {
"gt": "2018",
"lt": "2022"
}
}
},

given that this is a must query, does it make sense to move the range outside of the bool (as must is like an AND condition). However, I am not sure how to reorganize the query.

Can someone please help?

Hi @searchwithme

You didn't give much detail, but you could rearrange it like this:

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "movies-date": {
              "gt": "2018",
              "lt": "2022"
            }
          }
        }
      ],
      "must": [
        {
          .....
        }
      ]
    }
  }
}
1 Like

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