Can I aggregate using only part of a field?

One of the fields in my index is a version number, e.g. "3.0.7", stored as a keyword. I'd like to do aggregations using only part of the version. For example, I'd like a count of the number of documents for each major version (1.x, 2.x, etc).

I could create separate fields:

major_version: 3
minor_version: 3.0
patch_version: 3.0.7

But I'm wondering if there's another way to do this.

Another solution would be to use a Path Tokenizer with . as the delimiter and use fielddata to be able to compute aggs. Note that will use more HEAP.

1 Like

Brilliant! That's exactly the type of solution I was looking for. Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.