Thanks for your reply. In my case however i am unable to use terms aggregation because i want to group not by field, but by regex matching the field against possible patterns.
Using filters aggregation allows me to do something like this -
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.