# Long range not working

**URL:** <https://discuss.elastic.co/t/long-range-not-working/195096>\
**Category:** Elasticsearch\
**Created:** [August 13, 2019, 8:09pm UTC](https://discuss.elastic.co/t/long-range-not-working/195096 "2019-08-13T20:09:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Rezende](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas_rezende/32/43971_2.png) [@Lucas\_Rezende](https://discuss.elastic.co/u/Lucas_Rezende)\
**Post date:** [August 13, 2019, 8:09pm UTC](https://discuss.elastic.co/t/long-range-not-working/195096/1 "2019-08-13T20:09:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 14, 2019, 7:41am UTC](https://discuss.elastic.co/t/long-range-not-working/195096/2 "2019-08-14T07:41:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2019, 7:42am UTC](https://discuss.elastic.co/t/long-range-not-working/195096/3 "2019-09-11T07:42:07Z")

</div>

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