# Document in Search result, but can't get it using his id

**URL:** <https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653>\
**Category:** Elasticsearch\
**Created:** [November 9, 2012, 8:05pm UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653 "2012-11-09T20:05:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic\_Bertron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loic_bertron/32/1794_2.png) [@Loic\_Bertron](https://discuss.elastic.co/u/Loic_Bertron)\
**Post date:** [November 9, 2012, 8:05pm UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653/1 "2012-11-09T20:05:41Z")

</div>

Hi,

I having a weird issue. When I'm querying ElasticSearch, everything is  
fine, all my documents are retrieved :

{  
"took" : 1045,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 53065,  
"max\_score" : 5.1729774,  
"hits" : [ {  
"\_index" : "twitter2",  
"\_type" : "tweet",  
"\_id" : "262393493719240704",  
"\_score" : 5.1729774, "\_source" : {"retweeted":false,"source":"\<a href="http://blackberry.com/twitter" rel="nofollow"\>Twitter for BlackBerry®","favorited":false,"coordinates":null,"place":null,"retweet\_count":0,"entities":{"hashtags":[],"user\_mentions":[],"urls":[]},"truncated":false,"created\_at":"Sun Oct 28 03:20:58 +0000 2012","in\_reply\_to\_status\_id\_str":null,"contributors":null,"text":"Paris! Paris! Paris Saint-Germain!","user":{"friends\_count":"141","follow\_request\_sent":null,"profile\_image\_url":"[http://a0.twimg.com/profile\_images/2243028690/IMG-20120521-00134\_normal.jpg","profile\_sidebar\_fill\_color":"DDEEF6","profile\_background\_image\_url\_https":"https://si0.twimg.com/profile\_background\_images/560433165/6518-creepy-owl.jpg","profile\_background\_color":"C0DEED","notifications":null,"url":null,"id":"569084775","following":null,"is\_translator":false,"screen\_name":"Tantooowi","lang":"id","location":"","followers\_count":"162","statuses\_count":"1973","name":"Fransiskus](http://a0.twimg.com/profile_images/2243028690/IMG-20120521-00134_normal.jpg%22,%22profile_sidebar_fill_color%22:%22DDEEF6%22,%22profile_background_image_url_https%22:%22https://si0.twimg.com/profile_background_images/560433165/6518-creepy-owl.jpg%22,%22profile_background_color%22:%22C0DEED%22,%22notifications%22:null,%22url%22:null,%22id%22:%22569084775%22,%22following%22:null,%22is_translator%22:false,%22screen_name%22:%22Tantooowi%22,%22lang%22:%22id%22,%22location%22:%22%22,%22followers_count%22:%22162%22,%22statuses_count%22:%221973%22,%22name%22:%22Fransiskus) Tanto","description":"Life isn't about finding yourself. Life's about creating yourself. De Britto College, YK 0'13","favourites\_count":"0","profile\_background\_tile":true,"listed\_count":0,"profile\_link\_color":"0084B4","contributors\_enabled":false,"profile\_image\_url\_https":"[https://si0.twimg.com/profile\_images/2243028690/IMG-20120521-00134\_normal.jpg","profile\_sidebar\_border\_color":"C0DEED","created\_at":"Wed](https://si0.twimg.com/profile_images/2243028690/IMG-20120521-00134_normal.jpg%22,%22profile_sidebar_border_color%22:%22C0DEED%22,%22created_at%22:%22Wed) May 02 10:50:24 +0000 2012","utc\_offset":25200,"verified":false,"profile\_background\_image\_url":"[http://a0.twimg.com/profile\_background\_images/560433165/6518-creepy-owl.jpg","default\_profile":false,"protected":false,"id\_str":"569084775","profile\_text\_color":"333333","default\_profile\_image":false,"time\_zone":"Bangkok","profile\_use\_background\_image":true,"geo\_enabled":false},"in\_reply\_to\_user\_id":null,"id":"262393493719240704","in\_reply\_to\_status\_id":null,"geo":null,"in\_reply\_to\_user\_id\_str":null,"id\_str":"262393493719240704","in\_reply\_to\_screen\_name](http://a0.twimg.com/profile_background_images/560433165/6518-creepy-owl.jpg%22,%22default_profile%22:false,%22protected%22:false,%22id_str%22:%22569084775%22,%22profile_text_color%22:%22333333%22,%22default_profile_image%22:false,%22time_zone%22:%22Bangkok%22,%22profile_use_background_image%22:true,%22geo_enabled%22:false%7D,%22in_reply_to_user_id%22:null,%22id%22:%22262393493719240704%22,%22in_reply_to_status_id%22:null,%22geo%22:null,%22in_reply_to_user_id_str%22:null,%22id_str%22:%22262393493719240704%22,%22in_reply_to_screen_name)":null}  
},

But when i'm trying to get only one id, i got

{"\_index":"twitter2","\_type":"tweet","\_id":"262393493719240704","exists":false}

Do you have any idea ? I tried on all my nodes, but there is no way i can  
get this tweet back with his id.

--

---

<div class="post-metadata">

**Author:** ![Loic\_Bertron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loic_bertron/32/1794_2.png) [@Loic\_Bertron](https://discuss.elastic.co/u/Loic_Bertron)\
**Post date:** [November 9, 2012, 8:27pm UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653/2 "2012-11-09T20:27:39Z")

</div>

To add to my previous message, not of all tweets can't be retrieved by id.  
It seems to be random.  
I also checked my mapping, everything should be stored  
: [https://gist.github.com/4048019](https://gist.github.com/4048019)  
Also no error in logs.

- Loïc

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 9, 2012, 9:08pm UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653/3 "2012-11-09T21:08:35Z")

</div>

If you require only access to one document by id, you should use the GET  
API since it is near-realtime.

curl -XGET '[http://localhost:9200/twitter2/tweet/262393493719240704](http://localhost:9200/twitter2/tweet/262393493719240704)'

Was the tweet just indexed? In the document that is returned by the above  
query, there is an "id" field. Can you query against "id" and not "\_id"? I  
have never tried to query against the \_id field, mainly because it is a bad  
practice in Lucene, but I believe it should be indexed.

--

Ivan

On Fri, Nov 9, 2012 at 12:27 PM, Loïc Bertron [loic.bertron@gmail.com](mailto:loic.bertron@gmail.com)wrote:

> To add to my previous message, not of all tweets can't be retrieved by id.  
> It seems to be random.  
> I also checked my mapping, everything should be stored :  
> [Twitter Mapping · GitHub](https://gist.github.com/4048019)  
> Also no error in logs.
> 
> - Loïc
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 10, 2012, 2:12am UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653/4 "2012-11-10T02:12:28Z")

</div>

That sounds like a routing issues. Did you specify a routing value when  
tweets were indexed? If yes, then the same routing value should be  
specified with get request.

On Friday, November 9, 2012 3:27:40 PM UTC-5, Loïc Bertron wrote:

> To add to my previous message, not of all tweets can't be retrieved by id.  
> It seems to be random.  
> I also checked my mapping, everything should be stored :  
> [Twitter Mapping · GitHub](https://gist.github.com/4048019)  
> Also no error in logs.
> 
> - Loïc

--

---

<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:05am UTC](https://discuss.elastic.co/t/document-in-search-result-but-cant-get-it-using-his-id/9653/5 "2017-07-06T03:05:02Z")

</div>


