All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sksamuel.elastic4s.searches.aggs.GeoCentroidAggregationBuilder.scala Maven / Gradle / Ivy

package com.sksamuel.elastic4s.searches.aggs

import com.sksamuel.elastic4s.{EnumConversions, ScriptBuilder}
import org.elasticsearch.search.aggregations.AggregationBuilders
import org.elasticsearch.search.aggregations.metrics.geocentroid.GeoCentroidAggregationBuilder

import scala.collection.JavaConverters._

object GeoCentroidAggregationBuilder {

  def apply(agg: GeoCentroidAggregationDefinition): GeoCentroidAggregationBuilder = {
    val builder = AggregationBuilders.geoCentroid(agg.name)
    agg.field.foreach(builder.field)
    agg.missing.foreach(builder.missing)
    agg.format.foreach(builder.format)
    agg.valueType.map(EnumConversions.valueType).foreach(builder.valueType)
    agg.script.map(ScriptBuilder.apply).foreach(builder.script)
    SubAggsFn(builder, agg.subaggs)
    if (agg.metadata.nonEmpty) builder.setMetaData(agg.metadata.asJava)
    builder
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy