How to remove one element from the list type field from ElasticSearch.
There are some of my data and I want to remove some elements from a list type field.
// The data of user list with book field
[
{
"userId": "1",
"books": [
{
"id": "1",
"name": "book1"
},
{
"id": "2",
"name": "book2"
}
]
},
{
"userId": "2",
"books": [
{
"id": "2",
"name": "book2"
},
{
"id": "3",
"name": "book3"
}
]
},
{
"userId": "13",
"books": [
{
"id": "2",
"name": "book2"
},
{
"id": "5",
"name": "book5"
}
]
}
]
What I want to do:
find the users whose userId in [1, 2, 3], and delete the book with id 2 from their books list.
The result expected:
[
{
"userId": "1",
"books": [
{
"id": "1",
"name": "book1"
}
]
},
{
"userId": "2",
"books": [
{
"id": "3",
"name": "book3"
}
]
},
{
"userId": "13",
"books": [
{
"id": "2",
"name": "book2"
},
{
"id": "5",
"name": "book5"
}
]
}
]
I'm newer of ElasticSearch, it's a very difficult problem for me. It will be better if you can provide a request command of the Curl command.