# Nested Filter/Query on all fields

**URL:** <https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540>\
**Category:** Elasticsearch\
**Created:** [March 6, 2015, 12:02am UTC](https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540 "2015-03-06T00:02:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sagar\_Shah](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Sagar\_Shah](https://discuss.elastic.co/u/Sagar_Shah)\
**Post date:** [March 6, 2015, 12:02am UTC](https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540/1 "2015-03-06T00:02:45Z")

</div>

Hello everyone,  
Here's my sample data going into elastic Search.

{  
"date\_time\_utc": "2014-01-01 01:01:01.000",  
"details": "Details of the event",  
"tracking\_id": "Message Tracking Id",  
"enterprise\_application": "ENTP APP",  
"log\_level": "DEBUG",  
"application\_id": "342-34-254",  
"source": "Source",  
"log\_code": "MDG.00.05",  
"host": "127.0.0.1",  
"context":  
{  
"A": "123",  
"B": "456",  
"C": "789"  
}  
}

When I am preparing for a search request, I am finding some issue.  
Basically, I need a capability to search a user input across all the  
elements of nested object "context".  
Context might have nested fields under it on the fly. So I need some kind  
of wild card operation of the fields itself like (context.\*).

I found one way, but that searches on specific field within context like  
given below.

"nested": {  
"path": "context",  
"filter": {  
"bool": {  
"must": [  
{ "term": { "context.A: "0432" } }  
]  
}  
}  
}

Is there a way to search a user input across all the fields under context  
nested element? I do not wish to search through rest of the fields.

I would prefer filter over query here.

Please advise.

Appreciate your inputs!

Regards,  
Sagar Shah

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [March 6, 2015, 8:36am UTC](https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540/2 "2015-03-06T08:36:18Z")

</div>

You can use a multi-match query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

or copy all the fields you are interested in into a new field at index time  
using copy\_to:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Fri, Mar 6, 2015 at 1:02 AM, Sagar Shah [sagarshah1983@gmail.com](mailto:sagarshah1983@gmail.com) wrote:

> Hello everyone,  
> Here's my sample data going into elastic Search.
> 
> {  
> "date\_time\_utc": "2014-01-01 01:01:01.000",  
> "details": "Details of the event",  
> "tracking\_id": "Message Tracking Id",  
> "enterprise\_application": "ENTP APP",  
> "log\_level": "DEBUG",  
> "application\_id": "342-34-254",  
> "source": "Source",  
> "log\_code": "MDG.00.05",  
> "host": "127.0.0.1",  
> "context":  
> {  
> "A": "123",  
> "B": "456",  
> "C": "789"  
> }  
> }
> 
> When I am preparing for a search request, I am finding some issue.  
> Basically, I need a capability to search a user input across all the  
> elements of nested object "context".  
> Context might have nested fields under it on the fly. So I need some kind  
> of wild card operation of the fields itself like (context.\*).
> 
> I found one way, but that searches on specific field within context like  
> given below.
> 
> "nested": {  
> "path": "context",  
> "filter": {  
> "bool": {  
> "must": [  
> { "term": { "context.A: "0432" } }  
> ]  
> }  
> }  
> }
> 
> Is there a way to search a user input across all the fields under context  
> nested element? I do not wish to search through rest of the fields.
> 
> I would prefer filter over query here.
> 
> Please advise.
> 
> Appreciate your inputs!
> 
> Regards,  
> Sagar Shah
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D\_8jmSqmeeA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D_8jmSqmeeA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Sagar\_Shah](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Sagar\_Shah](https://discuss.elastic.co/u/Sagar_Shah)\
**Post date:** [March 6, 2015, 3:45pm UTC](https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540/3 "2015-03-06T15:45:52Z")

</div>

Thanks a ton Adrien.  
multi\_match did work!

Regards,  
Sagar Shah

On Fri, Mar 6, 2015 at 2:36 AM, Adrien Grand \<[adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com)

> wrote:

> You can use a multi-match query:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)  
> or copy all the fields you are interested in into a new field at index time  
> using copy\_to:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#copy-to)
> 
> On Fri, Mar 6, 2015 at 1:02 AM, Sagar Shah [sagarshah1983@gmail.com](mailto:sagarshah1983@gmail.com)  
> wrote:
> 
> > Hello everyone,  
> > Here's my sample data going into elastic Search.
> > 
> > {  
> > "date\_time\_utc": "2014-01-01 01:01:01.000",  
> > "details": "Details of the event",  
> > "tracking\_id": "Message Tracking Id",  
> > "enterprise\_application": "ENTP APP",  
> > "log\_level": "DEBUG",  
> > "application\_id": "342-34-254",  
> > "source": "Source",  
> > "log\_code": "MDG.00.05",  
> > "host": "127.0.0.1",  
> > "context":  
> > {  
> > "A": "123",  
> > "B": "456",  
> > "C": "789"  
> > }  
> > }
> > 
> > When I am preparing for a search request, I am finding some issue.  
> > Basically, I need a capability to search a user input across all the  
> > elements of nested object "context".  
> > Context might have nested fields under it on the fly. So I need some kind  
> > of wild card operation of the fields itself like (context.\*).
> > 
> > I found one way, but that searches on specific field within context like  
> > given below.
> > 
> > "nested": {  
> > "path": "context",  
> > "filter": {  
> > "bool": {  
> > "must": [  
> > { "term": { "context.A: "0432" } }  
> > ]  
> > }  
> > }  
> > }
> > 
> > Is there a way to search a user input across all the fields under context  
> > nested element? I do not wish to search through rest of the fields.
> > 
> > I would prefer filter over query here.
> > 
> > Please advise.
> > 
> > Appreciate your inputs!
> > 
> > Regards,  
> > Sagar Shah
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5e04b543-9275-4bda-8696-068dd723b1d8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Adrien Grand
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/WvKyfof\_6tU/unsubscribe](https://groups.google.com/d/topic/elasticsearch/WvKyfof_6tU/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D\_8jmSqmeeA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D_8jmSqmeeA%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D\_8jmSqmeeA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7SrWzZpRX5UoJi16m3N1knrxSEH%2BU%3D9cK%3D_8jmSqmeeA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--

Regards,  
Sagar Shah

Too many people think more of security instead of opportunity. They seem  
more afraid of life than death!!!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CANZnv5gG5kS-TZ6qaX81fjHn\_V3L%2BBukW3\_Y0s6%3DHefc2CTBSQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CANZnv5gG5kS-TZ6qaX81fjHn_V3L%2BBukW3_Y0s6%3DHefc2CTBSQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:28am UTC](https://discuss.elastic.co/t/nested-filter-query-on-all-fields/22540/4 "2017-07-06T00:28:02Z")

</div>


