# Mutliple nested types in the same query

**URL:** <https://discuss.elastic.co/t/mutliple-nested-types-in-the-same-query/37678>\
**Category:** Elasticsearch\
**Created:** [December 21, 2015, 9:52am UTC](https://discuss.elastic.co/t/mutliple-nested-types-in-the-same-query/37678 "2015-12-21T09:52:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lengoyvaerts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lengoyvaerts/32/6748_2.png) [@lengoyvaerts](https://discuss.elastic.co/u/lengoyvaerts)\
**Post date:** [December 21, 2015, 9:52am UTC](https://discuss.elastic.co/t/mutliple-nested-types-in-the-same-query/37678/1 "2015-12-21T09:52:07Z")

</div>

Hi

I started this discussion in the wrong place  
( [https://github.com/elastic/elasticsearch/issues/15503#issuecomment-166240728](https://github.com/elastic/elasticsearch/issues/15503#issuecomment-166240728)), so I'll post it here.

I have a question to which I can't seem to find an answer anywhere.

Let's say I have an Index type with a mapping that contains two or more nested types (parallel, not deeply nested - see below):

`...
"field1": {  
  "type": "nested", 
  "properties": {
    "subfield1": { "type": "string" },
    "subfield2": { "type": "integer" }
  }
},
"field2": {  
  "type": "nested", 
  "properties": {
    "subfield1": { "type": "string" },
    "subfield2": { "type": "integer" }
  }
}                 
...`

Now I want to use both these nested fields in the same query. To explain this with a simple example:

I want to know which records have:  
field1.subfield1 = "Hello world" and  
field2.subfield2 = 5.

How can I put this logic in a query?

---

<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 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/mutliple-nested-types-in-the-same-query/37678/2 "2017-07-05T23:29:35Z")

</div>


