updated Java API docs with the changes due to aggregator refactoring
This commit is contained in:
parent
86b0777392
commit
c3d652030c
|
@ -14,10 +14,9 @@ Here is an example on how to create the aggregation request:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
AggregationBuilder aggregation =
|
AggregationBuilder aggregation =
|
||||||
AggregationBuilders
|
AggregationBuilders
|
||||||
.children("agg")
|
.children("agg", "reseller"); <1>
|
||||||
.childType("reseller");
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
1. `"agg"` is the name of the aggregation and `"reseller"` is the child type
|
||||||
|
|
||||||
===== Use aggregation response
|
===== Use aggregation response
|
||||||
|
|
||||||
|
@ -34,4 +33,3 @@ import org.elasticsearch.search.aggregations.bucket.children.Children;
|
||||||
Children agg = sr.getAggregations().get("agg");
|
Children agg = sr.getAggregations().get("agg");
|
||||||
agg.getDocCount(); // Doc count
|
agg.getDocCount(); // Doc count
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ Here is an example on how to create the aggregation request:
|
||||||
[source,java]
|
[source,java]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
AggregationBuilders
|
AggregationBuilders
|
||||||
.filter("agg")
|
.filter("agg", QueryBuilders.termQuery("gender", "male"));
|
||||||
.filter(QueryBuilders.termQuery("gender", "male"));
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,4 +32,3 @@ import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
||||||
Filter agg = sr.getAggregations().get("agg");
|
Filter agg = sr.getAggregations().get("agg");
|
||||||
agg.getDocCount(); // Doc count
|
agg.getDocCount(); // Doc count
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,8 @@ Here is an example on how to create the aggregation request:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
AggregationBuilder aggregation =
|
AggregationBuilder aggregation =
|
||||||
AggregationBuilders
|
AggregationBuilders
|
||||||
.filters("agg")
|
.filters("agg", new KeyedFilter("men", QueryBuilders.termQuery("gender", "male")),
|
||||||
.filter("men", QueryBuilders.termQuery("gender", "male"))
|
new KeyedFilter("women", QueryBuilders.termQuery("gender", "female")));
|
||||||
.filter("women", QueryBuilders.termQuery("gender", "female"));
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,8 @@ Here is an example on how to create the aggregation request:
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
AggregationBuilder aggregation =
|
AggregationBuilder aggregation =
|
||||||
AggregationBuilders
|
AggregationBuilders
|
||||||
.geoDistance("agg")
|
.geoDistance("agg", new GeoPoint(48.84237171118314,2.33320027692004))
|
||||||
.field("address.location")
|
.field("address.location")
|
||||||
.point(new GeoPoint(48.84237171118314,2.33320027692004))
|
|
||||||
.unit(DistanceUnit.KILOMETERS)
|
.unit(DistanceUnit.KILOMETERS)
|
||||||
.addUnboundedTo(3.0)
|
.addUnboundedTo(3.0)
|
||||||
.addRange(3.0, 10.0)
|
.addRange(3.0, 10.0)
|
||||||
|
@ -57,4 +56,3 @@ key [*-3.0], from [0.0], to [3.0], doc_count [161]
|
||||||
key [3.0-10.0], from [3.0], to [10.0], doc_count [460]
|
key [3.0-10.0], from [3.0], to [10.0], doc_count [460]
|
||||||
key [10.0-500.0], from [10.0], to [500.0], doc_count [4925]
|
key [10.0-500.0], from [10.0], to [500.0], doc_count [4925]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ Here is an example on how to create the aggregation request:
|
||||||
[source,java]
|
[source,java]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
AggregationBuilders
|
AggregationBuilders
|
||||||
.nested("agg")
|
.nested("agg", "resellers");
|
||||||
.path("resellers");
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,4 +32,3 @@ import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
||||||
Nested agg = sr.getAggregations().get("agg");
|
Nested agg = sr.getAggregations().get("agg");
|
||||||
agg.getDocCount(); // Doc count
|
agg.getDocCount(); // Doc count
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ AggregationBuilder aggregation =
|
||||||
.terms("agg").field("gender")
|
.terms("agg").field("gender")
|
||||||
.subAggregation(
|
.subAggregation(
|
||||||
AggregationBuilders.topHits("top")
|
AggregationBuilders.topHits("top")
|
||||||
.setExplain(true)
|
.explain(true)
|
||||||
.setSize(1)
|
.size(1)
|
||||||
.setFrom(10)
|
.from(10)
|
||||||
);
|
);
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
@ -77,4 +77,3 @@ key [female], doc_count [4893]
|
||||||
-> id [AUnzSZzp9k7PKXtq04x8], _source [{"gender":"female",...}]
|
-> id [AUnzSZzp9k7PKXtq04x8], _source [{"gender":"female",...}]
|
||||||
-> id [AUnzSZ0W9k7PKXtq04yS], _source [{"gender":"female",...}]
|
-> id [AUnzSZ0W9k7PKXtq04yS], _source [{"gender":"female",...}]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ SearchResponse sr = node.client().prepareSearch()
|
||||||
AggregationBuilders.terms("by_country").field("country")
|
AggregationBuilders.terms("by_country").field("country")
|
||||||
.subAggregation(AggregationBuilders.dateHistogram("by_year")
|
.subAggregation(AggregationBuilders.dateHistogram("by_year")
|
||||||
.field("dateOfBirth")
|
.field("dateOfBirth")
|
||||||
.interval((DateHistogramInterval.YEAR)
|
.dateHistogramInterval((DateHistogramInterval.YEAR)
|
||||||
.subAggregation(AggregationBuilders.avg("avg_children").field("children"))
|
.subAggregation(AggregationBuilders.avg("avg_children").field("children"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -61,4 +61,3 @@ include::aggregations/metrics.asciidoc[]
|
||||||
=== Bucket aggregations
|
=== Bucket aggregations
|
||||||
|
|
||||||
include::aggregations/bucket.asciidoc[]
|
include::aggregations/bucket.asciidoc[]
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ SearchResponse sr = node.client().prepareSearch()
|
||||||
.addAggregation(
|
.addAggregation(
|
||||||
AggregationBuilders.dateHistogram("agg2")
|
AggregationBuilders.dateHistogram("agg2")
|
||||||
.field("birth")
|
.field("birth")
|
||||||
.interval(DateHistogramInterval.YEAR)
|
.dateHistogramInterval(DateHistogramInterval.YEAR)
|
||||||
)
|
)
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue