# EdgenGram minimum length not working

**URL:** <https://discuss.elastic.co/t/edgengram-minimum-length-not-working/43868>\
**Category:** Elasticsearch\
**Created:** [March 9, 2016, 7:21am UTC](https://discuss.elastic.co/t/edgengram-minimum-length-not-working/43868 "2016-03-09T07:21:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![voipoclay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/voipoclay/32/4372_2.png) [@voipoclay](https://discuss.elastic.co/u/voipoclay)\
**Post date:** [March 9, 2016, 7:21am UTC](https://discuss.elastic.co/t/edgengram-minimum-length-not-working/43868/1 "2016-03-09T07:21:48Z")

</div>

Hello,

I am trying to do a terms aggregation on edgengrams that are longer then X in length but the results are coming back empty. If i remove the script filter results come back fine. Any suggestions?

```
POST /carrieradvancelog-*/_search
{
   "query": {
      "filtered": {
         "query": {
            "match_all": {}
         },
         "filter": {
            "script": {
               "script": "doc['dst_user.prefixes'].value.length() > param1",
               "params": {
                  "param1": 1
               }
            }
         }
      }
   },
   "size": 0,
   "aggs": {
      "badroutes": {
         "terms": {
            "field": "dst_user.prefixes",
            "size": 10
         }
      }
   }
}
```

---

<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, 11:10pm UTC](https://discuss.elastic.co/t/edgengram-minimum-length-not-working/43868/2 "2017-07-05T23:10:02Z")

</div>

Closed on July 5, 2017, 11:10pm UTC


