Elasticsearch muat_not match on all elemets of array

i have multiple documents with a field containing an array : for example:
"person1" : [
{
"network" : "A"
},
{
"network" : "B"
},
]
"person2" : [
{
"network" : "A"
},
{
"network" : "C"
}
]

i want to look for all the people without network C. (only person1)

if i query with { "must_not" : [{ "match": { "network" : "C" } }

i get also the person2. (because there is a subDoc in the array that does not have network C)

how can i query that all elements in array will match my condition

Are you using nested type? What's the mapping?

yes we are using nested for this path.
the mapping for the "profiles"

"profiles": {
"type": "nested",
"properties": {
"ids": {
"type": "long"
},
"network": {
"type": "keyword",
"ignore_above": 256
},
"url": {
"type": "keyword",
"fields": {
"text": {
"type": "text",
"analyzer": "stop"
}
}
},
"username": {
"type": "keyword",
"ignore_above": 256
}
}
},

each person have multiply networks and i look for the ones without specific one

That's the reason IMO. So you probably need to use the include_in_parent option. So you can also query the flattened content.

i will check this option , do i need to create new mapping or this option can be updated?

You need to reindex.

thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.