# Using aggregations with a completion field

**URL:** <https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010>\
**Category:** Elasticsearch\
**Created:** [June 20, 2017, 12:49am UTC](https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010 "2017-06-20T00:49:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![esUser2](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@esUser2](https://discuss.elastic.co/u/esUser2)\
**Post date:** [June 20, 2017, 12:49am UTC](https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010/1 "2017-06-20T00:49:43Z")

</div>

I'm relatively new to Elasticsearch. I've used aggregations with a simple search query but I don't understand how to do aggregations using a suggester on an completion field.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 20, 2017, 8:47pm UTC](https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010/2 "2017-06-20T20:47:58Z")

</div>

I don't believe you can aggregate on completion fields. Completion fields are a bit special, and maintain their own data-structure to perform the fast completion suggester. So they aren't really compatible with search/aggregations.

What are you trying to do?

---

<div class="post-metadata">

**Author:** ![esUser2](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@esUser2](https://discuss.elastic.co/u/esUser2)\
**Post date:** [June 20, 2017, 9:04pm UTC](https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010/3 "2017-06-20T21:04:28Z")

</div>

I wanted to do a top hits aggregator with the results returned by the suggester. I ended up implementing an analyzer and adding it to the same field with a text type instead of doing the completion type.

I'm still confused what is the difference between the completion type and an analyzer with a text type? They seem to do the same thing but I'm able to do aggregations with the analyzer.

---

<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 18, 2017, 9:04pm UTC](https://discuss.elastic.co/t/using-aggregations-with-a-completion-field/90010/4 "2017-07-18T21:04:31Z")

</div>

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