Is it possible to query multiple nested objects on different paths in Elasticsearch? I can query one nested object on one path but I can't find the correct syntax to query two objects on different paths.
I need to query with the logic like the following:
{'query': {
'bool': {
'must': [
'nested': {
'path': 'Diagnosis',
'query': {
'bool': {
'must': [{'match_phrase': {'Diagnosis.Diagnosis': {'query': "epidemia"}}}]
}
}
},
'nested': {
'path': 'Demographic',
'query': {
'bool': {
'must': [{'match_phrase': {'Demographic.Gender': {'query': "female"}}}]
}
}
}
]
}
}}
The ultimate goal is to denormalize my PostgreSQL DB data (72 tables, over 1600 columns in total) and be able to use boolean queries over it.
It works, I missed curly brackets around nested
query.
The correct way:
{'query': {
'bool': {
'must': [
{'nested': {
'path': 'Diagnosis',
'query': {
'bool': {
'must': [{'match_phrase': {'Diagnosis.Diagnosis': {'query': "epidemia"}}}]
}
}
}},
{'nested': {
'path': 'Demographic',
'query': {
'bool': {
'must': [{'match_phrase': {'Demographic.Gender': {'query': "female"}}}]
}
}
}}
]
}
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With