[FEAT] top_hits aggregation is not implemented
Closed this issue · 0 comments
NikkyAI commented
Describe the enhancement
missing aggregation: top_hits
How do you think it should be done?
class TopHitsAggConfig : JsonDsl() {
var aggSize by property<Long>("size") // can't redefine Map.size sadly
var from by property<Long>()
var sort by property<List<Any>>()
}
fun TopHitsAggConfig.sort(block: SortBuilder.() -> Unit) {
val builder = SortBuilder()
block.invoke(builder)
sort = builder.sortFields
}
class TopHitsAgg(block: (TopHitsAggConfig.() -> Unit)? = null) : AggQuery("top_hits") {
init {
val config = TopHitsAggConfig()
block?.invoke(config)
put(name, config)
}
}
@Serializable
data class TopHitsAggregationResult(
val hits: List<SearchResponse.Hit>,
)
fun Aggregations?.topHitResult(name: String, json: Json = DEFAULT_JSON): TopHitsAggregationResult =
getAggResult(name, json)
Will you be able to help with a pull request?
probably will open a pull request once enough stuff accumulates