Why only one of these queries returns a record?

Could someone explain why these queries are not returning the same response?

This first query using script returns no records

GET /ind1/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "script": {
            "script": """
              doc['event_id'] == '10092831599'
              """
          }
        }
      ]
    }
  }
}

Whereas this query returns 1 record as expected.

GET /ind1/_search
{
  "query": {
    "term": {
      "event_id": "10092831599"
    }
  }
}

Why is the script query not working in the same way as the term query? I have tried using single-quotes, double-quotes, using as a param value, but always the same result.... no records found...

The event_id field is mapped as

"event_id" : {
  "type" : "keyword"
},

The script syntax is doc['event_id'].value. It's and old syntax who's reasoning is historical.

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