# Curl by id does not work although the doc exists

**URL:** <https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232>\
**Category:** Elasticsearch\
**Created:** [August 15, 2013, 8:07pm UTC](https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232 "2013-08-15T20:07:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhzhang\_email](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jhzhang\_email](https://discuss.elastic.co/u/jhzhang_email)\
**Post date:** [August 15, 2013, 8:07pm UTC](https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232/1 "2013-08-15T20:07:39Z")

</div>

Hi folks,

I'm new to ES.

curl to get a document by ID has stopped working for me. I'm pretty sure it  
used to work.

elasticsearch-0.90.1 local installation on my Mac. All default  
configurations.

I have a document type called "campaign". To start with, I used a (minimal)  
mapping:

```
    "campaign" : {
        "_id" : {
            "path" : "id"
        },
        "properties" : {
            "lastUpdateTime" : {"type" : "long", "store" : "yes", 

```

"index" : "not\_analyzed", "index\_name" : "last\_update\_ts"}  
}  
}

Note that I use the "id" field in the JSON doc as the doc ID. I then use  
the Java API to index JSON documents by calling  
"IndexRequestBuilder.setSource".

If I do a blank search:

curl -XGET localhost:9200/11009/campaign/\_search?pretty

I got a list of the docs I have indexed. For example (Note: the actual  
source is much more complex):

{  
"took" : 4,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 32,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "11009",  
"\_type" : "campaign",  
"\_id" : "519c12fee4b0efe5ddccf586",  
"\_score" : 1.0, "\_source" : {"id":"519c12fee4b0efe5ddccf586",  
"schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":1369197100571,  
"status":"ACTIVE"}  
},  
...

All looked good until I do a curl using the doc's \_id:

curl -XGET localhost:9200/11009/campaign/519c12fee4b0efe5ddccf586?pretty

and I got

{  
"\_index" : "11009",  
"\_type" : "campaign",  
"\_id" : "519c12fee4b0efe5ddccf586",  
"exists" : false  
}

So that's really weird. Even more strangely, I index a simple document  
through curl:

curl -XPOST localhost:9200/11009/campaign/ -d  
'{"id":"xyz","schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":1369197100571,"status":"ACTIVE"}}'

I can actually get the doc by

curl -XGET localhost:9200/11009/campaign/xyz

I have tried flush, refresh and restart the ES server. But it is still not  
working.

Could anybody shed some lights on this problem?

Thanks,  
James

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 17, 2013, 4:41pm UTC](https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232/2 "2013-08-17T16:41:37Z")

</div>

Hey,

just a wild guess: Have you used routing for this document, so that it  
might end up in a different shard as expected by get GET request? If so,  
you also have to supply the routing key when executing the GET request.

If this is not the case, can you create a gist for reproduction or is it  
really only this document?

--Alex

On Thu, Aug 15, 2013 at 10:07 PM, [jhzhang.email@gmail.com](mailto:jhzhang.email@gmail.com) wrote:

> Hi folks,
> 
> I'm new to ES.
> 
> curl to get a document by ID has stopped working for me. I'm pretty sure  
> it used to work.
> 
> elasticsearch-0.90.1 local installation on my Mac. All default  
> configurations.
> 
> I have a document type called "campaign". To start with, I used a  
> (minimal) mapping:
> 
> ```
> "campaign" : {
> "_id" : {
> "path" : "id"
> },
> "properties" : {
> "lastUpdateTime" : {"type" : "long", "store" : "yes",
> 
> ```
> 
> "index" : "not\_analyzed", "index\_name" : "last\_update\_ts"}  
> }  
> }
> 
> Note that I use the "id" field in the JSON doc as the doc ID. I then use  
> the Java API to index JSON documents by calling  
> "IndexRequestBuilder.setSource".
> 
> If I do a blank search:
> 
> curl -XGET localhost:9200/11009/campaign/\_search?pretty
> 
> I got a list of the docs I have indexed. For example (Note: the actual  
> source is much more complex):
> 
> {  
> "took" : 4,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 32,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "11009",  
> "\_type" : "campaign",  
> "\_id" : "519c12fee4b0efe5ddccf586",  
> "\_score" : 1.0, "\_source" : {"id":"519c12fee4b0efe5ddccf586",  
> "schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":  
> 1369197100571,"status":"ACTIVE"}  
> },  
> ...
> 
> All looked good until I do a curl using the doc's \_id:
> 
> curl -XGET localhost:9200/11009/campaign/519c12fee4b0efe5ddccf586?pretty
> 
> and I got
> 
> {  
> "\_index" : "11009",  
> "\_type" : "campaign",  
> "\_id" : "519c12fee4b0efe5ddccf586",  
> "exists" : false  
> }
> 
> So that's really weird. Even more strangely, I index a simple document  
> through curl:
> 
> curl -XPOST localhost:9200/11009/campaign/ -d  
> '{"id":"xyz","schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":1369197100571,"status":"ACTIVE"}}'
> 
> I can actually get the doc by
> 
> curl -XGET localhost:9200/11009/campaign/xyz
> 
> I have tried flush, refresh and restart the ES server. But it is still not  
> working.
> 
> Could anybody shed some lights on this problem?
> 
> Thanks,  
> James
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jhzhang\_email](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jhzhang\_email](https://discuss.elastic.co/u/jhzhang_email)\
**Post date:** [August 27, 2013, 12:19am UTC](https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232/3 "2013-08-27T00:19:37Z")

</div>

Hi Alex,

Spot on! That's exactly the cause.

I forgot I set a "parent" for this type, so the routing is the parent id.

Thanks.  
James

On Saturday, August 17, 2013 9:41:37 AM UTC-7, Alexander Reelsen wrote:

> Hey,
> 
> just a wild guess: Have you used routing for this document, so that it  
> might end up in a different shard as expected by get GET request? If so,  
> you also have to supply the routing key when executing the GET request.
> 
> If this is not the case, can you create a gist for reproduction or is it  
> really only this document?
> 
> --Alex
> 
> On Thu, Aug 15, 2013 at 10:07 PM, \<[jhzhan...@gmail.com](mailto:jhzhan...@gmail.com) \<javascript:\>\>wrote:
> 
> > Hi folks,
> > 
> > I'm new to ES.
> > 
> > curl to get a document by ID has stopped working for me. I'm pretty sure  
> > it used to work.
> > 
> > elasticsearch-0.90.1 local installation on my Mac. All default  
> > configurations.
> > 
> > I have a document type called "campaign". To start with, I used a  
> > (minimal) mapping:
> > 
> > ```
> > "campaign" : {
> > "_id" : {
> > "path" : "id"
> > },
> > "properties" : {
> > "lastUpdateTime" : {"type" : "long", "store" : "yes", 
> > 
> > ```
> > 
> > "index" : "not\_analyzed", "index\_name" : "last\_update\_ts"}  
> > }  
> > }
> > 
> > Note that I use the "id" field in the JSON doc as the doc ID. I then use  
> > the Java API to index JSON documents by calling  
> > "IndexRequestBuilder.setSource".
> > 
> > If I do a blank search:
> > 
> > curl -XGET localhost:9200/11009/campaign/\_search?pretty
> > 
> > I got a list of the docs I have indexed. For example (Note: the actual  
> > source is much more complex):
> > 
> > {  
> > "took" : 4,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 32,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "11009",  
> > "\_type" : "campaign",  
> > "\_id" : "519c12fee4b0efe5ddccf586",  
> > "\_score" : 1.0, "\_source" : {"id":"519c12fee4b0efe5ddccf586",  
> > "schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":  
> > 1369197100571,"status":"ACTIVE"}  
> > },  
> > ...
> > 
> > All looked good until I do a curl using the doc's \_id:
> > 
> > curl -XGET localhost:9200/11009/campaign/519c12fee4b0efe5ddccf586?pretty
> > 
> > and I got
> > 
> > {  
> > "\_index" : "11009",  
> > "\_type" : "campaign",  
> > "\_id" : "519c12fee4b0efe5ddccf586",  
> > "exists" : false  
> > }
> > 
> > So that's really weird. Even more strangely, I index a simple document  
> > through curl:
> > 
> > curl -XPOST localhost:9200/11009/campaign/ -d  
> > '{"id":"xyz","schemaVersion":1,"createTime":1369182974587,"lastUpdateTime":1369197100571,"status":"ACTIVE"}}'
> > 
> > I can actually get the doc by
> > 
> > curl -XGET localhost:9200/11009/campaign/xyz
> > 
> > I have tried flush, refresh and restart the ES server. But it is still  
> > not working.
> > 
> > Could anybody shed some lights on this problem?
> > 
> > Thanks,  
> > James
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:19am UTC](https://discuss.elastic.co/t/curl-by-id-does-not-work-although-the-doc-exists/13232/4 "2017-07-06T02:19:41Z")

</div>


