# Range for id

**URL:** <https://discuss.elastic.co/t/range-for-id/9754>\
**Category:** Elasticsearch\
**Created:** [November 18, 2012, 7:38pm UTC](https://discuss.elastic.co/t/range-for-id/9754 "2012-11-18T19:38:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sada](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@sada](https://discuss.elastic.co/u/sada)\
**Post date:** [November 18, 2012, 7:38pm UTC](https://discuss.elastic.co/t/range-for-id/9754/1 "2012-11-18T19:38:08Z")

</div>

Hello  
My need is to find the documents which \_id \> "50792fa924cc1e5028003fc0"

I'm trying to, for example:  
{"query": {"range": {"\_uid": {"gt": "50792fa924cc1e5028003fc0"}}}}

and ...

{"query": {"range": {"\_id": {"gt": "50792fa924cc1e5028003fc0"}}}}

no result

"query": {"term": {"\_id": "50792fa924cc1e5028003fc0"}}  
works well  
and  
"sort": [{"\_uid": "asc"}]  
works well

id - hexadecimal id of Mongo

Any clue ?

Thank you

sorry for my english

---

<div class="post-metadata">

**Author:** ![uboness1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uboness1/32/849_2.png) [@uboness1](https://discuss.elastic.co/u/uboness1)\
**Post date:** [November 18, 2012, 8:21pm UTC](https://discuss.elastic.co/t/range-for-id/9754/2 "2012-11-18T20:21:39Z")

</div>

Hi sada,

the \_id field is not indexed by default (only as part of the \_uid field which is a combi of both \_id & \_type - which is the reason why using \_uid in your queries won't help much in your case). You can configure it to be indexed in the mapping by defining something like:

"\_id" : { "index" : "not\_analyzed" }

cheers,  
Uri

--  
Uri Boness | Founder | Elasticsearch | [www.elasticsearch.com](http://www.elasticsearch.com) | +31 20 486 2036

On Sunday, November 18, 2012 at 8:41 PM, sada wrote:

> Hello  
> My need is to find the documents which \_id \> "50792fa924cc1e5028003fc0"
> 
> I'm trying to, for example:  
> {"query": {"range": {"\_uid": {"gt": "50792fa924cc1e5028003fc0"}}}}
> 
> and ...
> 
> {"query": {"range": {"\_id": {"gt": "50792fa924cc1e5028003fc0"}}}}
> 
> no result
> 
> "query": {"term": {"\_id": "50792fa924cc1e5028003fc0"}}  
> works well  
> and  
> "sort": [{"\_uid": "asc"}]  
> works well
> 
> id - hexadecimal id of Mongo
> 
> Any clue ?
> 
> Thank you
> 
> sorry for my english
> 
> --

--

---

<div class="post-metadata">

**Author:** ![sada](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@sada](https://discuss.elastic.co/u/sada)\
**Post date:** [November 18, 2012, 8:45pm UTC](https://discuss.elastic.co/t/range-for-id/9754/3 "2012-11-18T20:45:52Z")

</div>

Thank you for the quick response

---

<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:** [July 6, 2017, 3:03am UTC](https://discuss.elastic.co/t/range-for-id/9754/4 "2017-07-06T03:03:47Z")

</div>


