Terms aggregation split by whitespace

You have some examples of script processor here: https://www.elastic.co/guide/en/elasticsearch/reference/6.6/script-processor.html

I don't have example of splitting a text with a painless script but that should not be that hard to write one with something like https://docs.oracle.com/javase/8/docs/api/java/util/StringTokenizer.html#StringTokenizer-java.lang.String-. This class is supported by Painless. See https://www.elastic.co/guide/en/elasticsearch/painless/6.6/painless-api-reference.html