# Range queries

**URL:** <https://discuss.elastic.co/t/range-queries/223447>\
**Category:** Elasticsearch\
**Created:** [March 13, 2020, 4:46am UTC](https://discuss.elastic.co/t/range-queries/223447 "2020-03-13T04:46:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![afzal](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@afzal](https://discuss.elastic.co/u/afzal)\
**Post date:** [March 13, 2020, 4:46am UTC](https://discuss.elastic.co/t/range-queries/223447/1 "2020-03-13T04:46:54Z")

</div>

I have a source object similar to this

```
"_source" : {
      "phone" : "1234567890",
      "email" : "test_test.com",
      "group" : "test",
      "name" : "Rhonda Shawarma",
      "prop.size_min" : "0",
      "prop.size_max" : "1000000"
    }

```

I wrote a basic query on Kibana which works fine

```
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "prop.size_max": {
              "gte": "100"
            }
          }
        },
        {
          "range": {
            "prop.size_min": {
              "lte": "100"
            }
          }
        }
      ]
    }
  }
}

```

This returns the document for me but when I change lte and gte to "101" or even store them as integers and try it with 101 (Not as a string) then I don't get the document back. Is there something I'm missing or doing wrong here?

---

<div class="post-metadata">

**Author:** ![rameshkr1994](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshkr1994/32/59029_2.png) [@rameshkr1994](https://discuss.elastic.co/u/rameshkr1994)\
**Post date:** [March 13, 2020, 7:01am UTC](https://discuss.elastic.co/t/range-queries/223447/2 "2020-03-13T07:01:35Z")

</div>

Hi @afzal.

Please check here-

[range](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html)

Thanks  
HadoopHelp

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 13, 2020, 7:09am UTC](https://discuss.elastic.co/t/range-queries/223447/3 "2020-03-13T07:09:38Z")

</div>

What is the mapping?

---

<div class="post-metadata">

**Author:** ![afzal](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@afzal](https://discuss.elastic.co/u/afzal)\
**Post date:** [March 19, 2020, 5:30pm UTC](https://discuss.elastic.co/t/range-queries/223447/4 "2020-03-19T17:30:07Z")

</div>

My mapping was incorrect. Thanks for pointing it out. My initial data had string so ES created a string mapping so it didn't matter if I tried with long.  
After initializing the index with long for certain fields it was working fine. Thanks!

---

<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:** [April 16, 2020, 5:30pm UTC](https://discuss.elastic.co/t/range-queries/223447/5 "2020-04-16T17:30:16Z")

</div>

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