Hello experts
I have an index with accepts docs in JSON format. I have a specific JSON structure.
{
"title": "ABC",
"admissions": [
{
"location": "Sydney",
"year": 2020
},
{
"location": "Melbourne",
"year": 2020
},
{
"location": "Canberra",
"year": 2021
}
]
}
Requirement 1:
My requirement is that I can perform multi_match search on a single keyword but need to filter the record only if admissions.year >= 2021.
My original query to search "Melbourne"
{
"_source": {
"includes": [
"title",
"admissions"
]
},
"from": "0",
"size": "100",
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "Melbourne",
"fields": [
"title",
"admissions.location"
]
}
},
{
"nested": {
"path": "admissions",
"query": {
"bool": {
"must": [
{ "range": { "admissions.year": { "gte": "2021" } } }
]
}
}
}
}
]
}
}
}
This returns the record I have provided even though the there is no admission for location='Melbourne' and year >= 2021.
Requirement 2
If I search for keyword "ABC", I should be able to return the record.
Thanks
Paz