Opensearch documentation https://opensearch.org/docs/latest/field-types/supported-field-types/nested/
provides an example where a search will fail because arrays are flattened when stored:
PUT testindex1/_doc/100
{
"patients": [
{"name" : "John Doe", "age" : 56, "smoker" : true},
{"name" : "Mary Major", "age" : 85, "smoker" : false}
]
}
becomes:
{
"patients.name" : ["John Doe", "Mary Major"],
"patients.age" : [56, 85],
"patients.smoker" : [true, false]
}
Rather than use nested data types (which introduces a number of issues), why not make separate entries??
PUT testindex1/_doc/100
{
"patients": {"name" : "John Doe", "age" : 56, "smoker" : true}
}
PUT testindex1/_doc/100
{
"patients": {"name" : "Mary Major", "age" : 85, "smoker" : false}
}