Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a document with a forward-slash in id from Elasticsearch

I have a document as:

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

I tried to delete this record using:

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

This does not delete the entry as the forward slash in "id" field separates the query.

How can I delete this record from Elasticsearch? Any help is appreciated.

like image 253
Fleur Avatar asked Oct 20 '16 11:10

Fleur


1 Answers

You can do it in two ways. Either by referencing the document directly like this:

DELETE user_entity/users/U_6900%2F17

Or via an ids query like this:

DELETE user_entity/users/_query
{
    "query": {
        "ids": {
             "values": ["U_6900/17"]
        }
    }
}
like image 57
Val Avatar answered Nov 05 '22 01:11

Val