RareTerms aggregation does not support floating point fields – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.3-7.7

Briefly, this error occurs when you try to use the RareTerms aggregation on a field that is of a floating point type in Elasticsearch. RareTerms aggregation is designed to work with discrete values, not continuous ones. To resolve this issue, you can either change the field type to a non-floating point type if possible, or use a different type of aggregation that supports floating point fields, such as Histogram or Percentiles. Alternatively, you can round the floating point values to integers before indexing, if precision is not a critical factor.

This guide will help you check for common problems that cause the log ” RareTerms aggregation does not support floating point fields. ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “RareTerms aggregation does not support floating point fields.” class name is RareTermsAggregatorFactory.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
} if (valuesSource instanceof ValuesSource.Numeric) {
IncludeExclude.LongFilter longFilter = null;
if (((ValuesSource.Numeric) valuesSource).isFloatingPoint()) {
throw new AggregationExecutionException("RareTerms aggregation does not support floating point fields.");
}
if (includeExclude != null) {
longFilter = includeExclude.convertToLongFilter(config.format());
}
return new LongRareTermsAggregator(name; factories; (ValuesSource.Numeric) valuesSource; config.format();<p></p>
} if (valuesSource instanceof ValuesSource.Numeric) { IncludeExclude.LongFilter longFilter = null; if (((ValuesSource.Numeric) valuesSource).isFloatingPoint()) { throw new AggregationExecutionException("RareTerms aggregation does not support floating point fields."); } if (includeExclude != null) { longFilter = includeExclude.convertToLongFilter(config.format()); } return new LongRareTermsAggregator(name; factories; (ValuesSource.Numeric) valuesSource; config.format();<p></p>
 }  if (valuesSource instanceof ValuesSource.Numeric) {
 IncludeExclude.LongFilter longFilter = null;
 if (((ValuesSource.Numeric) valuesSource).isFloatingPoint()) {
 throw new AggregationExecutionException("RareTerms aggregation does not support floating point fields.");
 }
 if (includeExclude != null) {
 longFilter = includeExclude.convertToLongFilter(config.format());
 }
 return new LongRareTermsAggregator(name; factories; (ValuesSource.Numeric) valuesSource; config.format();

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?