# Aggregation on comma separated text field

**URL:** <https://discuss.elastic.co/t/aggregation-on-comma-separated-text-field/74791>\
**Category:** Kibana\
**Created:** [February 12, 2017, 6:59am UTC](https://discuss.elastic.co/t/aggregation-on-comma-separated-text-field/74791 "2017-02-12T06:59:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharatj](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sharatj](https://discuss.elastic.co/u/sharatj)\
**Post date:** [February 12, 2017, 6:59am UTC](https://discuss.elastic.co/t/aggregation-on-comma-separated-text-field/74791/1 "2017-02-12T06:59:56Z")

</div>

I have a field that contains comma separated values. I am trying to find the right way to define the tokenizer and analyzer so that I can aggregate on the individual values of the field instead of the entire value.

I was able to do this successfully in 2.3 with the string type. However, when I migrated that mapping to 5.3, the type was changed to text that behaves in a different way.

Things I tried to get the aggregation I need -

```
"tokenizer" : {
  "csv_token" : {
	"type" : "pattern",
	"pattern": ","
  }
},
"analyzer": {
	"csv": {
		"type": "custom",
		"tokenizer": "csv_token"
	}
}

"mappings": {
      "MyObject": {
        "properties": {
          "attributes": {
            "properties": {
              "csvvalues": {
                "type": "text",
                "analyzer": "csv"
              },
...

```

This doesn't seem to make the csvvalues field aggregatable in Kibana index and hence it doesn't appear in the Terms option in Visualize.

Any help will be appreciated!

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [February 13, 2017, 7:34pm UTC](https://discuss.elastic.co/t/aggregation-on-comma-separated-text-field/74791/2 "2017-02-13T19:34:16Z")

</div>

Note that Kibana/Elasticsearch 5.3 hasn't been released yet. Are you sure that's the version you are using?

I would guess this is happening because in 5.0+, Elasticsearch by default doesn't allow aggregations on analyzed fields, as fielddata is disabled by default. Your best bet is to index the data as separate keyword fields for a terms aggregation.

---

<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:** [March 13, 2017, 7:35pm UTC](https://discuss.elastic.co/t/aggregation-on-comma-separated-text-field/74791/3 "2017-03-13T19:35:21Z")

</div>

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