# Fetch results where count of nested field is more than 1

**URL:** <https://discuss.elastic.co/t/fetch-results-where-count-of-nested-field-is-more-than-1/351042>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [January 14, 2024, 11:59pm UTC](https://discuss.elastic.co/t/fetch-results-where-count-of-nested-field-is-more-than-1/351042 "2024-01-14T23:59:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hardik\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hardik_sharma/32/125160_2.png) [@Hardik\_Sharma](https://discuss.elastic.co/u/Hardik_Sharma)\
**Post date:** [January 14, 2024, 11:59pm UTC](https://discuss.elastic.co/t/fetch-results-where-count-of-nested-field-is-more-than-1/351042/1 "2024-01-14T23:59:11Z")

</div>

So I have a mapping where "configs" is a nested field.

```auto
["configs"]{
  "type": "nested",
  ["properties"]: {[56 items]
}}

```

Now I want to fetch docs where 'configs' have more than 1 objects.  
For this I am using

```auto
{
  "script": {
    "script": {
     "source": "doc['configs'].length > 1",
       "lang": "painless"
    }
  }
}

```

I have also tried .size() and .values.size()  
But it always gives error  
No field found for [configs] in mapping with types [inventory]

Can anyone provide any help here?

---

<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 11, 2024, 11:59pm UTC](https://discuss.elastic.co/t/fetch-results-where-count-of-nested-field-is-more-than-1/351042/2 "2024-02-11T23:59:32Z")

</div>

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