The fieldata disabled by default. You should enable it to use text field type in the aggregation or Kibana visualization.
Here is an example for you.
#push example data
PUT collection_test2/_doc/1
{"text_field":"word1 word2 word3"}
PUT collection_test2/_doc/2
{"text_field":"word2 word2 word3 word4"}
#enable the fielddata to true
PUT collection_test2/_mapping
{
"properties": {
"text_field": {
"type": "text",
"fielddata": true
}
}
}
#Create visualization or search your text field type data
GET collection_test2/_search
{
"size": 0,
"aggs": {
"NAME": {
"terms": {
"field": "text_field"
}
}
}
}
Note: You should update the Kibana data view after update the index mapping and refresh the browser => Stack Management => Data views => collection_test3 => refresh (there is a button for that)
Note2: The result will show the number of docs that contains per wordX.
