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
Describe the enhancement
missing aggregation:
top_hits
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
How do you think it should be done?
Will you be able to help with a pull request?
probably will open a pull request once enough stuff accumulates