# Aggregating fields without indexing it

**URL:** <https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105>\
**Category:** Elasticsearch\
**Created:** [November 24, 2016, 11:51am UTC](https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105 "2016-11-24T11:51:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shushu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shushu/32/10037_2.png) [@shushu](https://discuss.elastic.co/u/shushu)\
**Post date:** [November 24, 2016, 11:51am UTC](https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105/1 "2016-11-24T11:51:59Z")

</div>

Hi all,  
Trying to follow the example from [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#_time_series), I marked all of the fields as not indexed - but supposibly they should be aggregate-able.  
According to Kibana over the same fields, they are not.  
Looking into a solution, enabling [doc\_values](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html) suppose to do it - but seems like it does not work, and the dynamic field created does not have the doc\_values enabled.

Meanwhile it seems I must enable indexing for all fields in order to aggregate.  
Is this a known issue ?  
I am working on ES 5.

Thanks in advance,  
Shushu

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 24, 2016, 12:08pm UTC](https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105/2 "2016-11-24T12:08:42Z")

</div>

I just tried this using elasticsearch directly:

```
DELETE test
PUT test
{
   "settings": {
	  "number_of_replicas": 0,
	  "number_of_shards":1
   },
   "mappings": {
	  "test": {
				
		 "properties": {
			"longField": {
			   "type": "long",
				"index":false
			 }
		 }
	  }
   }
}
POST test/test
{
	"longField":12
}
GET test/_search
{
	"aggs":{
		"longs":{
			"sum":{
				"field":"longField"
			}
		}
	}
}

```

Elasticsearch correctly produces an aggregation because doc\_values are available (setting doc\_values explicitly to false in the mapping breaks this).  
I tried pointing Kibana at the same index and as you suggest it failed to recognise this as an aggregatable field. I suggest you raise this in the Kibana forum as that seems to be where the issue is.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 24, 2016, 1:48pm UTC](https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105/3 "2016-11-24T13:48:32Z")

</div>

OK there is an issue here with the metadata elasticsearch provides to Kibana to determine what is aggregatable. The api Kibana uses [1] currently only returns "isAggregatable" info on indexed fields.  
We'll take a closer look on how to address this but for now to work with Kibana it looks like the worka-around is you'll need indexed fields (with the baggage that incurs).

[1] [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-field-stats.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-field-stats.html)

---

<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 22, 2016, 1:49pm UTC](https://discuss.elastic.co/t/aggregating-fields-without-indexing-it/67105/4 "2016-12-22T13:49:25Z")

</div>

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