# Nested Filter Problem

**URL:** https://discuss.elastic.co/t/nested-filter-problem/116351
**Category:** Elasticsearch
**Created:** [January 20, 2018, 7:16pm UTC](https://discuss.elastic.co/t/nested-filter-problem/116351 "2018-01-20T19:16:01Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Arvind\_Rao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arvind_rao/32/26758_2.png) [@Arvind\_Rao](https://discuss.elastic.co/u/Arvind_Rao)
#### Post date: [January 22, 2018, 7:30am UTC](https://discuss.elastic.co/t/nested-filter-problem/116351/2 "2018-01-22T07:30:42Z")

</div>

See my response to a [similar question](https://discuss.elastic.co/t/querying-nested-datatype/116408)

In the context of queries on nested structures, an element in the "specs" array can either match "Tornillo" or "Dorado" but not both.

Try what I suggested in the other question, i.e. use the inner\_hits object to determine if the count of matched elements is 2. Only the records where it is 2 are valid results.

```auto
{
	"query": {
		"nested": {
			"path": "specs",
			"query": {
				"bool": {
					"filter": [{
							"terms": {
								"specs.value": [
									"Tornillo", "Dorado"
								]
							}
						}
					]
				}
			},
			"inner_hits": {}
		}
	}
}

```

---

_[View the full topic](https://discuss.elastic.co/t/nested-filter-problem/116351)._
