Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Describe the issue:
I am indexing the following doc
{
"patients": [
{"name" : "John Doe", "age" : 56, "smoker" : true},
{"name" : "Mary Major", "age" : 85, "smoker" : false}
]
}
with the following mapping
mapping = {
"mappings" : {
"properties": {
"patients": {
"type" : "nested"
}
}
}
}
for this query
{
"query": {
"nested": {
"path": "patients",
"query": {
"bool": {
"must": [
{
"term": {
"patients.smoker": false
}
},
{
"range": {
"patients.age": {
"gte": 75
}
}
}
]
}
}
}
}
}
response = client.search(index=index_name, body=query)
returns
{'took': 116, 'timed_out':
False, '_shards':
{'total': 3, 'successful': 3, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 1, 'relation': 'eq'}, 'max_score': 1.6931472, '
hits': [{'_index': 'test', '_id': 'U2j6iJ',
'_score': 1.6931472,
'_source':
{'patients': [{'name': 'John Doe', 'age': 56, 'smoker': True},
{'name': 'Mary Major', 'age': 85, 'smoker': False}]}}]}}
I expect this query only returns
Mary Major