# Regex on Term aggregations with phrase

**URL:** <https://discuss.elastic.co/t/regex-on-term-aggregations-with-phrase/66422>\
**Category:** Elasticsearch\
**Created:** [November 17, 2016, 3:47pm UTC](https://discuss.elastic.co/t/regex-on-term-aggregations-with-phrase/66422 "2016-11-17T15:47:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nero\_dante](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@Nero\_dante](https://discuss.elastic.co/u/Nero_dante)\
**Post date:** [November 17, 2016, 3:47pm UTC](https://discuss.elastic.co/t/regex-on-term-aggregations-with-phrase/66422/1 "2016-11-17T15:47:26Z")

</div>

How can I aggregate a term filter based on the phrase? The field auto is analyzed with shingle analyzer.The below query works fine with single keyword without whitespace when there is whitespace it fails. Any better way of doing it?

```
{
      "query" : {
        "prefix" : {
          "auto" : "Hello Wo*"
        }
      },
      "aggregations" : {
        "auto" : {
          "terms" : {
            "field" : "auto",
            "size" : 1000,
            "include" : "Hello Wo.*"
          }
        }
      }
    }
```

---

<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:** [December 15, 2016, 3:47pm UTC](https://discuss.elastic.co/t/regex-on-term-aggregations-with-phrase/66422/2 "2016-12-15T15:47:32Z")

</div>

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