String stats aggregation
/ String_stats, / AggregationString stats aggregation #
A multi-value metrics aggregation computing length and character statistics over keyword/string values: count, min/max/avg length and Shannon entropy of the character distribution.
How it works #
Every document that has a string value for the field contributes one string. Over those strings the engine reports:
count— how many values were seen (documents without the field are skipped, not counted);min_length,max_length,avg_length— length statistics in UTF-8 bytes, so a non-ASCII character counts as its encoded width;entropy— Shannon entropy of the pooled character frequencies, in bits:-Σ p(c) · log2 p(c)over the sharep(c)of each character across all strings. Constant text gives0; text where every character is equally likely giveslog2(alphabet size).
The character frequencies are pooled across all contributing values
before the entropy is taken, so repetition across documents counts: the
teaching type field repeats the same few words 120 times and still
scores ≈3.22 bits.