Remove document with forward slash ID from Elasticsearch

I have a document like:

{
    "_type": "users",
    "_id": "U_6900/17",
    "_source": {
        "name": "User name"
    }
}

I tried to delete this entry using:

DELETE user_entity/users/_query
{
    "query": {
        "term": {
             "id": "U_6900/17"
        }
    }
}

This does not delete the entry, because the slash in the id field separates the request.

How to remove this entry from Elasticsearch? Any help is appreciated.

+4
source share
1 answer

You can do this in two ways. Or, referring to the document directly, like this:

DELETE user_entity/users/U_6900%2F17

Or through idsquery as follows:

DELETE user_entity/users/_query
{
    "query": {
        "ids": {
             "values": ["U_6900/17"]
        }
    }
}
+3
source

Source: https://habr.com/ru/post/1658315/


All Articles