# Querying elasticsearch to find items whose nested objects all contain some values

**URL:** <https://discuss.elastic.co/t/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-values/20754>\
**Category:** Elasticsearch\
**Created:** [November 14, 2014, 4:14pm UTC](https://discuss.elastic.co/t/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-values/20754 "2014-11-14T16:14:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannis\_rossetto](https://avatars.discourse-cdn.com/v4/letter/y/6de8d8/32.png) [@yannis\_rossetto](https://discuss.elastic.co/u/yannis_rossetto)\
**Post date:** [November 14, 2014, 4:14pm UTC](https://discuss.elastic.co/t/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-values/20754/1 "2014-11-14T16:14:11Z")

</div>

Hi,

I posted this elsewhere but I thought some people on this list could be  
intersted by this too.

this is rather complex (at least to me). I have a load of items, let's say  
they are meals. It could look something like:

'index' : 'meals',  
'body' : {  
'name' : {'type' : 'string'},  
'dish' : {  
'type' : 'nested',  
'ingredients' : {'type' : 'array'},  
}  
}

Now, the first step is to find exactly ALL meals which contain butter in  
ALL of their dishes.

The ultimate goal is to find exactly ALL meals which contain butter OR  
margarine in ALL of their dishes.

Can anyone think how this can be done?

Thanks

P.S. Here too:  
[http://stackoverflow.com/questions/26929552/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-value](http://stackoverflow.com/questions/26929552/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-value)

--  
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/c789675f-d2e5-42d8-a6ce-224086ab8f2b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c789675f-d2e5-42d8-a6ce-224086ab8f2b%40googlegroups.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:49am UTC](https://discuss.elastic.co/t/querying-elasticsearch-to-find-items-whose-nested-objects-all-contain-some-values/20754/2 "2017-07-06T00:49:57Z")

</div>

Closed on July 6, 2017, 12:49am UTC


