To provide an example, I have data that looks like this:
"example": {
"abc": {
"field1":"value1"
},
"def": {
"field1":"value2"
},
"xyz": {
"field1":"value3"
}
}
I want to do a filter to return all documents where one of the objects nested in "example" has a "field1" of "value1". The complicating factor here is that the field names "abc," "def," and "xyz" are dynamic, so I can't do a term filter like "example.abc.field1 : value1", since I don't know the field name "abc". What I need is something like "example.*.field1 : value1". Is this possible to do in Elasticsearch?
I've also been looking into the has_child filter, but it appears that, unless I'm mistaken, this only works with arrays rather than objects. I know I could structure the field as an array and that would achieve the desired result, but that makes things difficult in the application layer since it requires me to iteratively search the array to find "example.xyz", which is not very scalable.
Thanks for your help!