# Query Syntax: How to build a multi-field combined query that supports nested documents?

**URL:** <https://discuss.elastic.co/t/query-syntax-how-to-build-a-multi-field-combined-query-that-supports-nested-documents/147789>\
**Category:** Elasticsearch\
**Created:** [September 7, 2018, 11:48pm UTC](https://discuss.elastic.co/t/query-syntax-how-to-build-a-multi-field-combined-query-that-supports-nested-documents/147789 "2018-09-07T23:48:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexu](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@alexu](https://discuss.elastic.co/u/alexu)\
**Post date:** [September 7, 2018, 11:48pm UTC](https://discuss.elastic.co/t/query-syntax-how-to-build-a-multi-field-combined-query-that-supports-nested-documents/147789/1 "2018-09-07T23:48:48Z")

</div>

I am looking for a query syntax that lets me do following search

WHERE  
(  
reference MATCH '\<match\_query\>' OR  
order.number MATCH '\<match\_query\>' OR  
order.items.comments MATCH '\<match\_query\>' OR  
)  
AND  
(  
reference MATCH\_WILDCARD '\<wildcard\_query\>' OR  
order.number MATCH\_WILDCARD '\<wildcard\_query\>' OR  
order.items.comments MATCH\_WILDCARD '\<wildcard\_query\>' OR  
)  
AND  
(  
reference NOT\_MATCH '\<not\_match\_query\>' OR  
order.number NOT\_MATCH '\<not\_match\_query\>' OR  
order.items.comments NOT\_MATCH '\<not\_match\_query\>' OR  
)

If I understand ES syntax correctly - I have to use "should" combination for each of the "OR" condition and set minimum\_should\_match to "1".

But I do not see how to combine multiple "bool\should" queries under single "must" parent?

Any ideas?

Thank you!

Alex

---

<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:** [October 5, 2018, 11:48pm UTC](https://discuss.elastic.co/t/query-syntax-how-to-build-a-multi-field-combined-query-that-supports-nested-documents/147789/2 "2018-10-05T23:48:58Z")

</div>

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