Filter on integer type filed thrown exception if the passed value is not correct integer format

My index has a field "Count" which is integer type and I would like to filter by this field as follows:

GET _search
{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "text": "quick brown fox"
        }
      },
      "filter": {
        "term": {
          "Count": "100"
        }
      }
    }
  }
}

It works if the passed the value is in correct integer format. But if I passed an value with incorrect integer format, ES thrown exception:

GET _search
{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "text": "quick brown fox"
        }
      },
      "filter": {
        "term": {
          "Count": "abc111"
        }
      }
    }
  }
}

exception:
  "caused_by": {
            "type": "number_format_exception",
            "reason": "For input string: \"abc111\"

Is there an elegant way to suppress the exception even the passed value is no in correct integer format?

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