I want to delete some documents from Elasticsearch.
I used this API DELETE /hiddenservices/_doc/[_id]
.(hiddenservices
is a name of index).
Generally, it worked well, but when the value of _id is a website URL, the API didn't work.
For example, let's say _id of one document is http://blablabla.blabla/.
In this case, the API will be DELETE /hiddenservices/_doc/http://blablabla.blabla/
and never work.
Because I don't have much experience in Elasticsearch, I am not sure how to fix this issue.
Please anyone help me with this...
@Val's answer is absolutely correct. But there is an alternative way if you don't feel like URL-encoding the id. You can simply use _bulk:
PUT hiddenservices/_bulk
{"index": {"_id": "http://blablabla.blabla/"}}
{ "some": "data" }
POST hiddenservices/_bulk
{"delete": {"_id": "http://blablabla.blabla/"}}
If documents were indexing with a custom routing because they have parent/child relationship or the routing was specified during indexing, this routing should be specified as well:
PUT hiddenservices/_bulk
{"index": {"_id": "http://blablabla.blabla/", "routing": "abc"}}
{ "some": "data" }
POST hiddenservices/_bulk
{"delete": {"_id": "http://blablabla.blabla/", "routing": "abc"}}