# Filter by sub objects count

**URL:** <https://discuss.elastic.co/t/filter-by-sub-objects-count/165777>\
**Category:** Elasticsearch\
**Created:** [January 25, 2019, 1:00pm UTC](https://discuss.elastic.co/t/filter-by-sub-objects-count/165777 "2019-01-25T13:00:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Behemo1h](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/behemo1h/32/130721_2.png) [@Behemo1h](https://discuss.elastic.co/u/Behemo1h)\
**Post date:** [January 25, 2019, 1:00pm UTC](https://discuss.elastic.co/t/filter-by-sub-objects-count/165777/1 "2019-01-25T13:00:57Z")

</div>

Hi guys. I have data in my index like this.  
"locales" : {  
"en\_US" : {  
"title\_full" : "some text",  
"title" : "some text"  
},  
"fr\_FR" : {  
"title\_full" : "some text",  
"title" : "some text"  
}  
},

How can i filter documents by count of sub objects in field like "where.locales.count() \< 3".

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 25, 2019, 1:32pm UTC](https://discuss.elastic.co/t/filter-by-sub-objects-count/165777/2 "2019-01-25T13:32:11Z")

</div>

Typically something to solve at index time.  
You might use a painless script query but I feel it might be super slow.  
Adding the size at index time will definitely help IMHO.

---

<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:** [February 22, 2019, 1:32pm UTC](https://discuss.elastic.co/t/filter-by-sub-objects-count/165777/3 "2019-02-22T13:32:12Z")

</div>

Closed on February 22, 2019, 1:32pm UTC

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