Number is equal to Query?

I want to check if a number is equal to some other in my query.

Let's put in some test data:

PUT newindex/test/123
{
  "num":20
}
PUT newindex/test/12
{
  "num":20.0
}

Now I want to return all cases where num is 20 - so both results.

A term query doesn't work, since one of the numbers is 20.0.

Neither does this range query:

GET newindex/_search
{
  "query": {
    "range": {
      "num": {
        "gte": 20,
        "lte": 20
        
      }
    }
  }
}

This does, but it's a hack, and not very robust:

GET newindex/_search
{
  "query": {
    "range": {
      "num": {
        "gte": 20,
        "lte": 20.0
        
      }
    }
  }
}

Is there no way to create such a straightforward query?

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