# Elastic Search Query help

**URL:** <https://discuss.elastic.co/t/elastic-search-query-help/261656>\
**Category:** Elasticsearch\
**Created:** [January 20, 2021, 1:26pm UTC](https://discuss.elastic.co/t/elastic-search-query-help/261656 "2021-01-20T13:26:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pazhanikanthan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pazhanikanthan/32/82617_2.png) [@Pazhanikanthan](https://discuss.elastic.co/u/Pazhanikanthan)\
**Post date:** [January 20, 2021, 1:26pm UTC](https://discuss.elastic.co/t/elastic-search-query-help/261656/1 "2021-01-20T13:26:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 17, 2021, 1:26pm UTC](https://discuss.elastic.co/t/elastic-search-query-help/261656/2 "2021-02-17T13:26:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
