'Range filter in openSearch, ElasticSearch is not working correctly

I have a problem while using Opensearch which based on Elasticsearch when I use range as filter query I get all the data that apply to the filter query despite it doesn't match the search query with a score of 0.0 down below sample of the query I use

{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
            "match": {
              "FIELD": "TEXT"
            }
              },
              {
                "match": {
                 "FIELD": "TEXT"
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                 "match": {
                 "FIELD": "TEXT"
                }
              },
              {
                "match": {
                 "FIELD": "TEXT"
                }
              }
            ]
          }
        }
      ],
      "filter": [
        {
          "range": {
            "FIELD": {
              "gt": 1,
              "lt": 500
            }
          }
        }
      ]
    }
  }
}

what I want is to get all the data that only match the search Query and it matches the filter at the same time and I don't know what I'm doing wrong any help. Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source