I'm trying to get the the documents that match all the itens inside a list, the field that I'm searching for is inside a list of nested :
map of my index:
PUT testindex1
{
"mappings": {
"properties": {
"patients": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"age": {
"type": "keyword"
}
}
}
}
}
}
Documents
PUT testindex1/_doc/1
{
"patients": [
{"name" : "1", "age" : "1"},
{"name" : "1", "age" : "2"},
{"name" : "1", "age" : "3"}
]
}
PUT testindex1/_doc/2
{
"patients": [
{"name" : "1", "age" : "1"},
{"name" : "1", "age" : "2"},
{"name" : "1", "age" : "3"}
]
}
PUT testindex1/_doc/3
{
"patients":[
{"name" : "1", "age" : "2"},
{"name" : "1", "age" : "5"},
{"name" : "1", "age" : "4"}
]
}
what I'm trying to get is all the documents where the patients ages are inside have list ["2", "1"], in this case only the document 1
and 2
. I know that i can update the map by using
this approach
But this would mean that I would have to reprocess the entire dataset
get patients that have both ages "1" and "2" (only patients of index 1 and 2)