So you cannot aggregate on a text field. You need to have the mapping set to keyword for you to be able to do that.
For the existing text field - if you want to make it make it aggregatable -
you have to do this:
Switching from a text field to a keyword field
If you previously used a text field to index unstructured machine-generated content, you can reindex to update the mapping to a keyword or wildcard field. We also recommend you update your application or workflow to replace any word-based full text queries on the field to equivalent term-level queries.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.