Curl by id does not work although the doc exists

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.
For more options, visit https://groups.google.com/groups/opt_out.

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 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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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 <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 <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.