# Query for specific traits in a household

**URL:** <https://discuss.elastic.co/t/query-for-specific-traits-in-a-household/194332>\
**Category:** Elasticsearch\
**Created:** [August 7, 2019, 9:42pm UTC](https://discuss.elastic.co/t/query-for-specific-traits-in-a-household/194332 "2019-08-07T21:42:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marksparrish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marksparrish/32/105857_2.png) [@marksparrish](https://discuss.elastic.co/u/marksparrish)\
**Post date:** [August 7, 2019, 9:42pm UTC](https://discuss.elastic.co/t/query-for-specific-traits-in-a-household/194332/1 "2019-08-07T21:42:02Z")

</div>

I am trying to retrieve all of the household that have only females in it.  
My document structure is -

> ```
> name_first: keyword
> name_middle: keyword
> name_last: keyword
> physical_address_id: keyword
> gender: keyword
> 
> ```

Gender is M,F,O

I can get the aggregation with

> ```
> {
> "size" : 0,
> "_source" : false,
> "stored_fields" : "_none_",
> "aggregations" : {
> "groupby" : {
> "composite" : {
> "size" : 1000,
> "sources" : [
> {
> "769" : {
> "terms" : {
> "field" : "physical_id.keyword",
> "missing_bucket" : true,
> "order" : "asc"
> }
> }
> },
> {
> "746" : {
> "terms" : {
> "field" : "gender.keyword",
> "missing_bucket" : true,
> "order" : "asc"
> }
> }
> }
> ]
> }
> }
> }
> }
> 
> ```

This is where I'm stuck. Post Filter does not see to fit or at least I can't get it to work.

---

<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:** [September 4, 2019, 9:42pm UTC](https://discuss.elastic.co/t/query-for-specific-traits-in-a-household/194332/2 "2019-09-04T21:42:04Z")

</div>

Closed on September 4, 2019, 9:42pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
