Long range not working

Hi there. I am trying range filter based on a long attribute but it seems not to be working.

This is the que query I am using:

GET my_index/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "statistics.stats_last_purchase_minus_six_months"
          }
        },
        {
          "range": {
            "user_account_profile.user_account_id": {
              "gte": 0,
              "lt": 10000
            }
          }
        }
      ]
    }
  }
}

This is the mapping of this attribute:

"user_account_id": {
    "type": "long"
}

An this is part of a document that is being returned:

...
"user_account_id" : 5489108
...

By the way, I see that many documents returns this attribute as string even with the right mapping (as shown above).

Example:

...
"user_account_id" : "5258648"
...

Can I get some help?

can you provide a fully reproducible example, including documents and index creation as well and the elasticsearch version you are using, please?

Also, you put that range clause in a must_not query, so all documents that do not match that condition will be included.

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