Sampler aggregation cannot be applied to field – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.7

Briefly, this error occurs when you try to apply a sampler aggregation to a field type that doesn’t support it. Sampler aggregation is used to select a subset of documents, but not all field types are compatible. To resolve this issue, you can either change the field type to one that supports sampler aggregation, or use a different type of aggregation that is compatible with the current field type. Alternatively, you can create a new field with a compatible type and copy the values from the original field.

This guide will help you check for common problems that cause the log ” Sampler aggregation cannot be applied to field [ ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “Sampler aggregation cannot be applied to field [” class name is DiversifiedAggregatorFactory.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 }
 return execution.create(name; factories; shardSize; maxDocsPerValue; valuesSource; searchContext; parent; pipelineAggregators;
 metaData);
 }  throw new AggregationExecutionException("Sampler aggregation cannot be applied to field [" + config.fieldContext().field()
 + "]. It can only be applied to numeric or string fields.");
 }  @Override
 protected Aggregator createUnmapped(SearchContext searchContext;

 

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?