I have an elastic index with the below mapping. It has an array of vehicle and each array element contains array of info elements.
PUT test_nested_query
{
"mappings": {
"_doc": {
"properties": {
"vehicle": {
"type": "nested",
"properties": {
"name": {
"type": "text"
},
"info": {
"type": "nested",
"properties": {
"type": {
"type": "text"
},
"reported_at": {
"type": "date"
},
"created_at": {
"type": "date"
}
}
}
}
}
}
}
}
}
Sample documents in the index
POST test_nested_query/_doc/1
{
"vehicle": [
{
"name": "1",
"info": [
{
"type": "A",
"reported_at": 1582950792000,
"created_at": 1582950792000
}
]
},
{
"name": "2",
"info": [
{
"type": "B",
"created_at": 1582950792000
}
]
}
]
}
POST test_nested_query/_doc/2
{
"vehicle": [
{
"name": "1"
}
]
}
I want to search for documents that have no info present at any level
OR if info present at any level then resported_at must be present at the same level
.
I am using Elastic Search version 6.5.0.
I am allowed to modify the mapping at the info level but not at the vehicle level.