I am using aggregations on Elasticsearch through Java API. I can see up until the response object is returned, that aggregations are there within the response
But Postman returns this:
Any idea why or how to debug this even further? Is spring-data-elasticsearch doing something which I don't understand here?
Update: I have a hunch it has to do with jackson mapping somehow? Getting this as one of the bucket results:
I should be expecting something like this:
CodePudding user response:
Try to remove the numberOfHits
there is a limit size for aggregation
https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779
CodePudding user response:
It started working after I commented out this line:
mvc:
converters:
preferred-json-mapper: gson
in my application.yml. So now its using the jackson mapper. Also added this:
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilderCustomizer changeKeyAsNumber() {
return new Jackson2ObjectMapperBuilderCustomizer() {
@Override
public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
jacksonObjectMapperBuilder.mixIn(ParsedStringTerms.ParsedBucket.class, MixIn.class);
}
};
}
}
abstract class MixIn {
@JsonIgnore
abstract public Number getKeyAsNumber();
}
according to: Getting jackson parsing error while serializing AggregatedPage in spring data elasticsearch