# Multiple must tokens on nested object fields

**URL:** <https://discuss.elastic.co/t/multiple-must-tokens-on-nested-object-fields/7669>\
**Category:** Elasticsearch\
**Created:** [May 12, 2012, 5:57am UTC](https://discuss.elastic.co/t/multiple-must-tokens-on-nested-object-fields/7669 "2012-05-12T05:57:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Hsueh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frank_hsueh/32/2889_2.png) [@Frank\_Hsueh](https://discuss.elastic.co/u/Frank_Hsueh)\
**Post date:** [May 12, 2012, 5:57am UTC](https://discuss.elastic.co/t/multiple-must-tokens-on-nested-object-fields/7669/1 "2012-05-12T05:57:40Z")

</div>

help! I can't figure out how to apply a must filter on a nested type.

I tried a filter/nested with query/bool/must which doesn't work. anybody  
done this kind of thing before ?

mapping

> > > >

{  
"someobject" : {  
"properties" : {  
"organization" : {  
"type" : "nested",  
"properties" : {  
"filtername" : { "type" : "string", "index" : "not\_analyzed" },  
"foldername" : { "type" : "string", "index" : "not\_analyzed" },  
"hidden" : { "type" : "boolean" }  
}  
},  
"otherfields" : {  
"type" : "string",  
}  
}  
}  
}  
\<\<\<\<

my best guess is:

> > > >

{  
"filter": {  
"nested": {  
"path": "organization",  
"query": {  
"bool": {  
"must": [  
{ "term": { "organization.hidden": { "value": "false" } } },  
{ "term": { "organization.filtername": { "value": "myfilter" }  
} },  
{ "term": { "organization.foldername": { "value": "myfolder" }  
} }  
]  
}  
}  
}  
}  
}  
\<\<\<\<

--  
Frank Hsueh | [frank.hsueh@gmail.com](mailto:frank.hsueh@gmail.com)

---

<div class="post-metadata">

**Author:** ![Frank\_Hsueh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frank_hsueh/32/2889_2.png) [@Frank\_Hsueh](https://discuss.elastic.co/u/Frank_Hsueh)\
**Post date:** [May 12, 2012, 3:19pm UTC](https://discuss.elastic.co/t/multiple-must-tokens-on-nested-object-fields/7669/2 "2012-05-12T15:19:41Z")

</div>

ha ha ... I woke up this morning and found

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

and it works!

On Fri, May 11, 2012 at 10:57 PM, Frank Hsueh [frank.hsueh@gmail.com](mailto:frank.hsueh@gmail.com) wrote:

> help! I can't figure out how to apply a must filter on a nested type.
> 
> I tried a filter/nested with query/bool/must which doesn't work. anybody  
> done this kind of thing before ?
> 
> mapping
> 
> > > > >
> 
> {  
> "someobject" : {  
> "properties" : {  
> "organization" : {  
> "type" : "nested",  
> "properties" : {  
> "filtername" : { "type" : "string", "index" : "not\_analyzed" },  
> "foldername" : { "type" : "string", "index" : "not\_analyzed" },  
> "hidden" : { "type" : "boolean" }  
> }  
> },  
> "otherfields" : {  
> "type" : "string",  
> }  
> }  
> }  
> }  
> \<\<\<\<
> 
> my best guess is:
> 
> > > > >
> 
> {  
> "filter": {  
> "nested": {  
> "path": "organization",  
> "query": {  
> "bool": {  
> "must": [  
> { "term": { "organization.hidden": { "value": "false" } } },  
> { "term": { "organization.filtername": { "value": "myfilter" }  
> } },  
> { "term": { "organization.foldername": { "value": "myfolder" }  
> } }  
> ]  
> }  
> }  
> }  
> }  
> }  
> \<\<\<\<
> 
> --  
> Frank Hsueh | [frank.hsueh@gmail.com](mailto:frank.hsueh@gmail.com)

--  
Frank Hsueh | [frank.hsueh@gmail.com](mailto:frank.hsueh@gmail.com)

---

<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, 3:29am UTC](https://discuss.elastic.co/t/multiple-must-tokens-on-nested-object-fields/7669/3 "2017-07-06T03:29:09Z")

</div>


