Just now a strange thing happened. I used ran a search request on an elasticsearch cluster.
curl http://<cluster>/<index>/_search -H 'Content-Type: application/json' -d' { "query": { "match": { "<field>": "<value>" } } } '
The response was
{ "hits": { "hits": [{ "_id": "<the ID>", ... }], ... }, ... }
Then I tried to query this doc.
curl http://<cluster>/<index>/_doc/<the ID>
But it responded
{"_index":"<index>","_type":"_doc","_id":"<the ID>","found":false}
I tried to delete this record, but it was also not found.
{"_index":"<index>","_type":"_doc","_id":"<the ID>","_version":1,"result":"not_found","_shards":{ ... }, ... }
I finally used delete by query.
What could possibily cause this issue?
Elasticsearch version: 7.10.2
CodePudding user response:
It usually means that the record was indexed with a routing value, which means you need to provide that routing value to retrieve it, update it and/or delete it.
You can try different routing values, up to the number of primary shards that you have, i.e. if you have 5 primary shards, one of the following must return your document
curl http://<cluster>/<index>/_doc/<the ID>?routing=0
curl http://<cluster>/<index>/_doc/<the ID>?routing=1
curl http://<cluster>/<index>/_doc/<the ID>?routing=2
curl http://<cluster>/<index>/_doc/<the ID>?routing=3
curl http://<cluster>/<index>/_doc/<the ID>?routing=4
You can find the routing value used for your document in the search response in the _routing
field value.
{ "hits": { "hits": [{ "_id": "<the ID>", "_routing": "<the ROUTING>", ... }], ... }, ... }