# NEST 2.2 - Term Query and Nested Term Query

**URL:** <https://discuss.elastic.co/t/nest-2-2-term-query-and-nested-term-query/48572>\
**Category:** Elasticsearch\
**Created:** [April 27, 2016, 3:46pm UTC](https://discuss.elastic.co/t/nest-2-2-term-query-and-nested-term-query/48572 "2016-04-27T15:46:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![whittssg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whittssg/32/27669_2.png) [@whittssg](https://discuss.elastic.co/u/whittssg)\
**Post date:** [April 27, 2016, 3:46pm UTC](https://discuss.elastic.co/t/nest-2-2-term-query-and-nested-term-query/48572/1 "2016-04-27T15:46:21Z")

</div>

Hello, is there a way to get a Term Query and a nested query to work in the same query? As in match the parent doc to this and child doc to something else. I tried this but its only matching the child query:

```
.Query(f => f
                    .Bool(b1 => b1
                        .Must(m1 => m1
                            .Terms(t => t
                                .Field(p => p.Username)
                                .Terms(userlist)
                            ))
                        .Must(m2 => m2
                            .Nested(n => n
                                .Path("notes")
                                .Query(q2 => q2

                                    .Terms(t => t
                                        .Field(pp => pp.Notes.First().Username)
                                        .Terms(userlist)

                                    )))
                        )
                    )
                )

```

The query comes back but its only matching the child docs to my userlist not the parent. I would like to get back all master documents where the user is on the parent doc and in the child docs. Thanks

---

<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, 10:55pm UTC](https://discuss.elastic.co/t/nest-2-2-term-query-and-nested-term-query/48572/2 "2017-07-05T22:55:52Z")

</div>


