# Elasticsearch range query

**URL:** <https://discuss.elastic.co/t/elasticsearch-range-query/130419>\
**Category:** Elasticsearch\
**Created:** [May 3, 2018, 9:54am UTC](https://discuss.elastic.co/t/elasticsearch-range-query/130419 "2018-05-03T09:54:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [May 3, 2018, 9:54am UTC](https://discuss.elastic.co/t/elasticsearch-range-query/130419/1 "2018-05-03T09:54:30Z")

</div>

Hi All,

I have a problem while searching records using range query in the below format,  
{  
"query": {  
"range" : {  
"identification.numberOfEmployees.value" : {  
"gt" : "5",  
"lt" : "10"  
}  
}  
}  
}  
When I am trying to execute above query, i am getting empty result, but when I am trying with below query,  
{  
"query": {  
"range" : {  
"identification.numberOfEmployees.value" : {  
"gt" : "5"  
}  
}  
}  
}  
I am able to get the result.  
Could someone please help me on why its failing in the first scenario.

Thanks & Regards,  
Ram Prasad G

---

<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:** [May 3, 2018, 10:07am UTC](https://discuss.elastic.co/t/elasticsearch-range-query/130419/2 "2018-05-03T10:07:04Z")

</div>

If `identification.numberOfEmployees.value` is a `text` field, then I believe this is the issue.  
You need to change it as a number field.

---

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [May 3, 2018, 10:50am UTC](https://discuss.elastic.co/t/elasticsearch-range-query/130419/3 "2018-05-03T10:50:55Z")

</div>

thank you very much david. that resolved my problem.

---

<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:** [May 31, 2018, 10:51am UTC](https://discuss.elastic.co/t/elasticsearch-range-query/130419/4 "2018-05-31T10:51:03Z")

</div>

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