Search code examples
elasticsearchelasticsearch-java-apielasticsearch-6

Elasticsearch 6.1.1 Java Api, Missing child aggregation


Doing a long overdue upgrade from ES 2.X to ES 6.1.1. I have changed the parent/child mapping to be the join type so it is valid for 6.X. However we need to use a children aggregation.

The docs say it is available: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_bucket_aggregations.html#java-aggs-bucket-children

However if you look at the java docs it is not available: https://artifacts.elastic.co/javadoc/org/elasticsearch/elasticsearch/6.1.1/org/elasticsearch/search/aggregations/AggregationBuilders.html

What is the correct way to build a children aggregation for Elasticsearch 6.X since the java API is not available? Is the only way to create and send a request not using the java transport client?


Solution

  • I found my answer by searching through tests. Join type aggregations have their own builder now.

    import org.elasticsearch.join.aggregations.{ChildrenAggregationBuilder, JoinAggregationBuilders}
    

    The Elasticsearch documentation is out of date apparently and the JoinAggregationBuilders is not in the javadocs. https://github.com/elastic/elasticsearch/blob/bd92e7fa5e5fdc625249707ecf371781b157d668/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenIT.java#L48