The first thing that comes into my mind is to create a scripted field, let's say prefix that would use subsring function under the hood, so that you can apply any aggregations (incl. count) on this new field.
Thank you Aza,
that sounds amazing but I don't even know where to start implementing your suggestion. If you have a moment I would greatly appreciate if you break it down a bit for me.
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.