# Aggregation on non-indexed fields

**URL:** <https://discuss.elastic.co/t/aggregation-on-non-indexed-fields/125912>\
**Category:** Elasticsearch\
**Created:** [March 28, 2018, 10:55am UTC](https://discuss.elastic.co/t/aggregation-on-non-indexed-fields/125912 "2018-03-28T10:55:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sundar\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundar_v/32/6928_2.png) [@Sundar\_V](https://discuss.elastic.co/u/Sundar_V)\
**Post date:** [March 28, 2018, 10:55am UTC](https://discuss.elastic.co/t/aggregation-on-non-indexed-fields/125912/1 "2018-03-28T10:55:28Z")

</div>

Hello,

We are having in one ES 5.4, with 3 nodes and in total 80 shard.

We have 800 million documents in these shards. When we are aggregating on certain fields, we see that it is very slow.

The fields we are aggregating are count and millisecond.

```
"count": {
  "type": "long",
  "doc_values": true
},
"millisecond": {
  "type": "scaled_float",
  "scaling_factor": 100,
  "doc_values": true
},

```

We are not searching these fields, only aggregating. Should these be indexed?

From an old thread, it seems that indexing is not needed. [https://github.com/elastic/elasticsearch/issues/9762#issuecomment-75062924](https://github.com/elastic/elasticsearch/issues/9762#issuecomment-75062924)

Is that still valid with the new ES 5.x?

Thanks  
Sundar.

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [March 28, 2018, 12:46pm UTC](https://discuss.elastic.co/t/aggregation-on-non-indexed-fields/125912/2 "2018-03-28T12:46:45Z")

</div>

Yep. Agg uses doc\_values. You can try profile the query.

---

<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:** [April 25, 2018, 12:46pm UTC](https://discuss.elastic.co/t/aggregation-on-non-indexed-fields/125912/3 "2018-04-25T12:46:56Z")

</div>

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