package com.sooka.sponest.middleware.base.config; import com.fasterxml.jackson.annotation.JsonIgnore; import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class JacksonConfig { @Bean public Jackson2ObjectMapperBuilderCustomizer changeKeyAsNumber() { return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.mixIn(ParsedStringTerms.ParsedBucket.class, MixIn.class); } interface MixIn { @JsonIgnore Number getKeyAsNumber(); } }