mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
Remove redundant marker interfaces that extend Bucket (#127038)
No need to have these marker interfaces around when weäre not using them anywhere, all they do is hide a lot of code duplication actually. Removing them sets up the possible removal of hundreds of lines of downstream code it seems
This commit is contained in:
parent
b46bee4e47
commit
f461f90d48
71 changed files with 258 additions and 437 deletions
|
@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.PipelineAggregatorBuilders;
|
import org.elasticsearch.search.aggregations.PipelineAggregatorBuilders;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
@ -327,7 +327,7 @@ public class TimeSeriesAggregationsIT extends AggregationIntegTestCase {
|
||||||
SimpleValue obj = aggregations.get("total_filter_sum");
|
SimpleValue obj = aggregations.get("total_filter_sum");
|
||||||
assertThat(obj.value(), closeTo(sumByMetric(filteredData, "metric_" + metric), obj.value() * 0.0001));
|
assertThat(obj.value(), closeTo(sumByMetric(filteredData, "metric_" + metric), obj.value() * 0.0001));
|
||||||
|
|
||||||
Global global = aggregations.get("everything");
|
SingleBucketAggregation global = aggregations.get("everything");
|
||||||
Sum allSum = global.getAggregations().get("all_sum");
|
Sum allSum = global.getAggregations().get("all_sum");
|
||||||
assertThat(allSum.value(), closeTo(sumByMetric(data, "metric_" + metric), allSum.value() * 0.0001));
|
assertThat(allSum.value(), closeTo(sumByMetric(data, "metric_" + metric), allSum.value() * 0.0001));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.client.internal.Requests;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Sum;
|
import org.elasticsearch.search.aggregations.metrics.Sum;
|
||||||
import org.elasticsearch.search.aggregations.metrics.TopHits;
|
import org.elasticsearch.search.aggregations.metrics.TopHits;
|
||||||
|
@ -47,7 +48,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch("test").setQuery(matchQuery("randomized", true)).addAggregation(children("to_comment", "comment")),
|
prepareSearch("test").setQuery(matchQuery("randomized", true)).addAggregation(children("to_comment", "comment")),
|
||||||
response -> {
|
response -> {
|
||||||
Children childrenAgg = response.getAggregations().get("to_comment");
|
SingleBucketAggregation childrenAgg = response.getAggregations().get("to_comment");
|
||||||
assertThat("Response: " + response + "\n", childrenAgg.getDocCount(), equalTo(count));
|
assertThat("Response: " + response + "\n", childrenAgg.getDocCount(), equalTo(count));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -73,7 +74,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
assertThat(categoryBucket.getKeyAsString(), equalTo(entry1.getKey()));
|
assertThat(categoryBucket.getKeyAsString(), equalTo(entry1.getKey()));
|
||||||
assertThat(categoryBucket.getDocCount(), equalTo((long) entry1.getValue().articleIds.size()));
|
assertThat(categoryBucket.getDocCount(), equalTo((long) entry1.getValue().articleIds.size()));
|
||||||
|
|
||||||
Children childrenBucket = categoryBucket.getAggregations().get("to_comment");
|
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_comment");
|
||||||
assertThat(childrenBucket.getName(), equalTo("to_comment"));
|
assertThat(childrenBucket.getName(), equalTo("to_comment"));
|
||||||
assertThat(childrenBucket.getDocCount(), equalTo((long) entry1.getValue().commentIds.size()));
|
assertThat(childrenBucket.getDocCount(), equalTo((long) entry1.getValue().commentIds.size()));
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -113,7 +114,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
|
|
||||||
for (Terms.Bucket bucket : categoryTerms.getBuckets()) {
|
for (Terms.Bucket bucket : categoryTerms.getBuckets()) {
|
||||||
logger.info("bucket={}", bucket.getKey());
|
logger.info("bucket={}", bucket.getKey());
|
||||||
Children childrenBucket = bucket.getAggregations().get("to_comment");
|
SingleBucketAggregation childrenBucket = bucket.getAggregations().get("to_comment");
|
||||||
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
|
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
|
||||||
logger.info("total_hits={}", topHits.getHits().getTotalHits().value());
|
logger.info("total_hits={}", topHits.getHits().getTotalHits().value());
|
||||||
for (SearchHit searchHit : topHits.getHits()) {
|
for (SearchHit searchHit : topHits.getHits()) {
|
||||||
|
@ -125,7 +126,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
assertThat(categoryBucket.getKeyAsString(), equalTo("a"));
|
assertThat(categoryBucket.getKeyAsString(), equalTo("a"));
|
||||||
assertThat(categoryBucket.getDocCount(), equalTo(3L));
|
assertThat(categoryBucket.getDocCount(), equalTo(3L));
|
||||||
|
|
||||||
Children childrenBucket = categoryBucket.getAggregations().get("to_comment");
|
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_comment");
|
||||||
assertThat(childrenBucket.getName(), equalTo("to_comment"));
|
assertThat(childrenBucket.getName(), equalTo("to_comment"));
|
||||||
assertThat(childrenBucket.getDocCount(), equalTo(2L));
|
assertThat(childrenBucket.getDocCount(), equalTo(2L));
|
||||||
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
|
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
|
||||||
|
@ -178,7 +179,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch(indexName).addAggregation(children("children", "child").subAggregation(sum("counts").field("count"))),
|
prepareSearch(indexName).addAggregation(children("children", "child").subAggregation(sum("counts").field("count"))),
|
||||||
response -> {
|
response -> {
|
||||||
Children children = response.getAggregations().get("children");
|
SingleBucketAggregation children = response.getAggregations().get("children");
|
||||||
assertThat(children.getDocCount(), equalTo(4L));
|
assertThat(children.getDocCount(), equalTo(4L));
|
||||||
|
|
||||||
Sum count = children.getAggregations().get("counts");
|
Sum count = children.getAggregations().get("counts");
|
||||||
|
@ -205,7 +206,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
|
|
||||||
public void testNonExistingChildType() throws Exception {
|
public void testNonExistingChildType() throws Exception {
|
||||||
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(children("non-existing", "xyz")), response -> {
|
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(children("non-existing", "xyz")), response -> {
|
||||||
Children children = response.getAggregations().get("non-existing");
|
SingleBucketAggregation children = response.getAggregations().get("non-existing");
|
||||||
assertThat(children.getName(), equalTo("non-existing"));
|
assertThat(children.getName(), equalTo("non-existing"));
|
||||||
assertThat(children.getDocCount(), equalTo(0L));
|
assertThat(children.getDocCount(), equalTo(0L));
|
||||||
});
|
});
|
||||||
|
@ -264,7 +265,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
|
|
||||||
Children childrenAgg = response.getAggregations().get("my-refinements");
|
SingleBucketAggregation childrenAgg = response.getAggregations().get("my-refinements");
|
||||||
assertThat(childrenAgg.getDocCount(), equalTo(7L));
|
assertThat(childrenAgg.getDocCount(), equalTo(7L));
|
||||||
|
|
||||||
Terms termsAgg = childrenAgg.getAggregations().get("my-colors");
|
Terms termsAgg = childrenAgg.getAggregations().get("my-colors");
|
||||||
|
@ -316,7 +317,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 1L);
|
assertHitCount(response, 1L);
|
||||||
|
|
||||||
Children children = response.getAggregations().get(parentType);
|
SingleBucketAggregation children = response.getAggregations().get(parentType);
|
||||||
assertThat(children.getName(), equalTo(parentType));
|
assertThat(children.getName(), equalTo(parentType));
|
||||||
assertThat(children.getDocCount(), equalTo(1L));
|
assertThat(children.getDocCount(), equalTo(1L));
|
||||||
children = children.getAggregations().get(childType);
|
children = children.getAggregations().get(childType);
|
||||||
|
@ -379,7 +380,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
||||||
assertThat(parents.getBuckets().size(), equalTo(2));
|
assertThat(parents.getBuckets().size(), equalTo(2));
|
||||||
assertThat(parents.getBuckets().get(0).getKeyAsString(), equalTo("Alice"));
|
assertThat(parents.getBuckets().get(0).getKeyAsString(), equalTo("Alice"));
|
||||||
assertThat(parents.getBuckets().get(0).getDocCount(), equalTo(1L));
|
assertThat(parents.getBuckets().get(0).getDocCount(), equalTo(1L));
|
||||||
Children children = parents.getBuckets().get(0).getAggregations().get("child_docs");
|
SingleBucketAggregation children = parents.getBuckets().get(0).getAggregations().get("child_docs");
|
||||||
assertThat(children.getDocCount(), equalTo(1L));
|
assertThat(children.getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
assertThat(parents.getBuckets().get(1).getKeyAsString(), equalTo("Bill"));
|
assertThat(parents.getBuckets().get(1).getKeyAsString(), equalTo("Bill"));
|
||||||
|
|
|
@ -11,6 +11,7 @@ package org.elasticsearch.join.aggregations;
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -39,7 +40,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch("test").setSize(0).setQuery(matchQuery("randomized", true)).addAggregation(parent("to_article", "comment")),
|
prepareSearch("test").setSize(0).setQuery(matchQuery("randomized", true)).addAggregation(parent("to_article", "comment")),
|
||||||
response -> {
|
response -> {
|
||||||
Parent parentAgg = response.getAggregations().get("to_article");
|
SingleBucketAggregation parentAgg = response.getAggregations().get("to_article");
|
||||||
assertThat("\nResponse: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
|
assertThat("\nResponse: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -56,7 +57,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
.setQuery(matchQuery("randomized", true))
|
.setQuery(matchQuery("randomized", true))
|
||||||
.addAggregation(parent("to_article", "comment").subAggregation(terms("category").field("category").size(10000))),
|
.addAggregation(parent("to_article", "comment").subAggregation(terms("category").field("category").size(10000))),
|
||||||
response -> {
|
response -> {
|
||||||
Parent parentAgg = response.getAggregations().get("to_article");
|
SingleBucketAggregation parentAgg = response.getAggregations().get("to_article");
|
||||||
assertThat("Response: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
|
assertThat("Response: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
|
||||||
Terms categoryTerms = parentAgg.getAggregations().get("category");
|
Terms categoryTerms = parentAgg.getAggregations().get("category");
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -123,7 +124,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
equalTo((long) comments.size())
|
equalTo((long) comments.size())
|
||||||
);
|
);
|
||||||
|
|
||||||
Parent articleAgg = commenterBucket.getAggregations().get("to_article");
|
SingleBucketAggregation articleAgg = commenterBucket.getAggregations().get("to_article");
|
||||||
assertThat(articleAgg.getName(), equalTo("to_article"));
|
assertThat(articleAgg.getName(), equalTo("to_article"));
|
||||||
// find all articles for the comments for the current commenter
|
// find all articles for the comments for the current commenter
|
||||||
Set<String> articles = articleToControl.values()
|
Set<String> articles = articleToControl.values()
|
||||||
|
@ -159,7 +160,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
assertThat(categoryBucket.getKeyAsString(), equalTo(commenter));
|
assertThat(categoryBucket.getKeyAsString(), equalTo(commenter));
|
||||||
assertThat(categoryBucket.getDocCount(), equalTo((long) commenterToComments.get(commenter).size()));
|
assertThat(categoryBucket.getDocCount(), equalTo((long) commenterToComments.get(commenter).size()));
|
||||||
|
|
||||||
Parent childrenBucket = categoryBucket.getAggregations().get("to_article");
|
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_article");
|
||||||
assertThat(childrenBucket.getName(), equalTo("to_article"));
|
assertThat(childrenBucket.getName(), equalTo("to_article"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +187,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
|
|
||||||
public void testNonExistingParentType() throws Exception {
|
public void testNonExistingParentType() throws Exception {
|
||||||
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(parent("non-existing", "xyz")), response -> {
|
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(parent("non-existing", "xyz")), response -> {
|
||||||
Parent parent = response.getAggregations().get("non-existing");
|
SingleBucketAggregation parent = response.getAggregations().get("non-existing");
|
||||||
assertThat(parent.getName(), equalTo("non-existing"));
|
assertThat(parent.getName(), equalTo("non-existing"));
|
||||||
assertThat(parent.getDocCount(), equalTo(0L));
|
assertThat(parent.getDocCount(), equalTo(0L));
|
||||||
});
|
});
|
||||||
|
@ -216,7 +217,7 @@ public class ParentIT extends AbstractParentChildTestCase {
|
||||||
equalTo((long) comments.size())
|
equalTo((long) comments.size())
|
||||||
);
|
);
|
||||||
|
|
||||||
Parent articleAgg = commenterBucket.getAggregations().get("to_article");
|
SingleBucketAggregation articleAgg = commenterBucket.getAggregations().get("to_article");
|
||||||
assertThat(articleAgg.getName(), equalTo("to_article"));
|
assertThat(articleAgg.getName(), equalTo("to_article"));
|
||||||
// find all articles for the comments for the current commenter
|
// find all articles for the comments for the current commenter
|
||||||
Set<String> articles = articleToControl.values()
|
Set<String> articles = articleToControl.values()
|
||||||
|
|
|
@ -31,8 +31,7 @@ import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field;
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field;
|
||||||
|
@ -433,8 +432,8 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
||||||
assertThat(response.getHits().getAt(0).getId(), anyOf(equalTo("p2"), equalTo("p1")));
|
assertThat(response.getHits().getAt(0).getId(), anyOf(equalTo("p2"), equalTo("p1")));
|
||||||
assertThat(response.getHits().getAt(1).getId(), anyOf(equalTo("p2"), equalTo("p1")));
|
assertThat(response.getHits().getAt(1).getId(), anyOf(equalTo("p2"), equalTo("p1")));
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
Filter filter = global.getAggregations().get("filter");
|
SingleBucketAggregation filter = global.getAggregations().get("filter");
|
||||||
Terms termsFacet = filter.getAggregations().get("facet1");
|
Terms termsFacet = filter.getAggregations().get("facet1");
|
||||||
assertThat(termsFacet.getBuckets().size(), equalTo(2));
|
assertThat(termsFacet.getBuckets().size(), equalTo(2));
|
||||||
assertThat(termsFacet.getBuckets().get(0).getKeyAsString(), equalTo("red"));
|
assertThat(termsFacet.getBuckets().get(0).getKeyAsString(), equalTo("red"));
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.join.aggregations;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An single bucket aggregation that translates parent documents to their children documents.
|
|
||||||
*/
|
|
||||||
public interface Children extends SingleBucketAggregation {}
|
|
|
@ -19,7 +19,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Results of the {@link ParentToChildrenAggregator}.
|
* Results of the {@link ParentToChildrenAggregator}.
|
||||||
*/
|
*/
|
||||||
public class InternalChildren extends InternalSingleBucketAggregation implements Children {
|
public class InternalChildren extends InternalSingleBucketAggregation {
|
||||||
public InternalChildren(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
public InternalChildren(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Results of the {@link ChildrenToParentAggregator}.
|
* Results of the {@link ChildrenToParentAggregator}.
|
||||||
*/
|
*/
|
||||||
public class InternalParent extends InternalSingleBucketAggregation implements Parent {
|
public class InternalParent extends InternalSingleBucketAggregation {
|
||||||
public InternalParent(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
public InternalParent(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,18 @@
|
||||||
|
|
||||||
package org.elasticsearch.join.aggregations;
|
package org.elasticsearch.join.aggregations;
|
||||||
|
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
|
|
||||||
public abstract class JoinAggregationBuilders {
|
public abstract class JoinAggregationBuilders {
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Children} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static ChildrenAggregationBuilder children(String name, String childType) {
|
public static ChildrenAggregationBuilder children(String name, String childType) {
|
||||||
return new ChildrenAggregationBuilder(name, childType);
|
return new ChildrenAggregationBuilder(name, childType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Parent} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static ParentAggregationBuilder parent(String name, String childType) {
|
public static ParentAggregationBuilder parent(String name, String childType) {
|
||||||
return new ParentAggregationBuilder(name, childType);
|
return new ParentAggregationBuilder(name, childType);
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.join.aggregations;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An single bucket aggregation that translates child documents to their parent documents.
|
|
||||||
*/
|
|
||||||
public interface Parent extends SingleBucketAggregation {}
|
|
|
@ -34,7 +34,7 @@ import org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.SearchHits;
|
import org.elasticsearch.search.SearchHits;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -306,7 +306,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
prepareSearch("tests").setQuery(QueryBuilders.matchQuery("name", "bar"))
|
prepareSearch("tests").setQuery(QueryBuilders.matchQuery("name", "bar"))
|
||||||
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name"))),
|
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name"))),
|
||||||
searchResponse -> {
|
searchResponse -> {
|
||||||
Global global = searchResponse.getAggregations().get("global");
|
SingleBucketAggregation global = searchResponse.getAggregations().get("global");
|
||||||
Terms terms = global.getAggregations().get("test");
|
Terms terms = global.getAggregations().get("test");
|
||||||
assertThat(terms.getBuckets().size(), equalTo(4));
|
assertThat(terms.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name")))
|
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name")))
|
||||||
.addSort("_index", SortOrder.ASC),
|
.addSort("_index", SortOrder.ASC),
|
||||||
searchResponse -> {
|
searchResponse -> {
|
||||||
Global global = searchResponse.getAggregations().get("global");
|
SingleBucketAggregation global = searchResponse.getAggregations().get("global");
|
||||||
Terms terms = global.getAggregations().get("test");
|
Terms terms = global.getAggregations().get("test");
|
||||||
assertThat(terms.getBuckets().size(), equalTo(4));
|
assertThat(terms.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ package org.elasticsearch.search.aggregations;
|
||||||
|
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
|
@ -69,7 +69,7 @@ public class CombiIT extends ESIntegTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
InternalAggregations aggs = response.getAggregations();
|
InternalAggregations aggs = response.getAggregations();
|
||||||
|
|
||||||
Missing missing = aggs.get("missing_values");
|
SingleBucketAggregation missing = aggs.get("missing_values");
|
||||||
assertNotNull(missing);
|
assertNotNull(missing);
|
||||||
assertThat(missing.getDocCount(), equalTo(finalMissingValues));
|
assertThat(missing.getDocCount(), equalTo(finalMissingValues));
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.elasticsearch.script.MockScriptPlugin;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
|
||||||
|
@ -191,7 +191,7 @@ public class EquivalenceIT extends ESIntegTestCase {
|
||||||
assertEquals(bucket.getKeyAsString(), Integer.toString(i), bucket.getKeyAsString());
|
assertEquals(bucket.getKeyAsString(), Integer.toString(i), bucket.getKeyAsString());
|
||||||
assertEquals(bucket.getKeyAsString(), count, bucket.getDocCount());
|
assertEquals(bucket.getKeyAsString(), count, bucket.getDocCount());
|
||||||
|
|
||||||
final Filter filter = response.getAggregations().get("filter" + i);
|
final SingleBucketAggregation filter = response.getAggregations().get("filter" + i);
|
||||||
assertThat(filter.getDocCount(), equalTo(count));
|
assertThat(filter.getDocCount(), equalTo(count));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -430,7 +430,7 @@ public class EquivalenceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Filter filter = response.getAggregations().get("filter");
|
SingleBucketAggregation filter = response.getAggregations().get("filter");
|
||||||
assertNotNull(filter);
|
assertNotNull(filter);
|
||||||
assertEquals(1, filter.getDocCount());
|
assertEquals(1, filter.getDocCount());
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.Sampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregator;
|
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregator;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
||||||
|
@ -107,7 +106,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
assertThat(genreBuckets.size(), greaterThan(1));
|
assertThat(genreBuckets.size(), greaterThan(1));
|
||||||
double lastMaxPrice = asc ? Double.MIN_VALUE : Double.MAX_VALUE;
|
double lastMaxPrice = asc ? Double.MIN_VALUE : Double.MAX_VALUE;
|
||||||
for (Terms.Bucket genreBucket : genres.getBuckets()) {
|
for (Terms.Bucket genreBucket : genres.getBuckets()) {
|
||||||
Sampler sample = genreBucket.getAggregations().get("sample");
|
SingleBucketAggregation sample = genreBucket.getAggregations().get("sample");
|
||||||
Max maxPriceInGenre = sample.getAggregations().get("max_price");
|
Max maxPriceInGenre = sample.getAggregations().get("max_price");
|
||||||
double price = maxPriceInGenre.value();
|
double price = maxPriceInGenre.value();
|
||||||
if (asc) {
|
if (asc) {
|
||||||
|
@ -133,7 +132,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
List<? extends Bucket> testBuckets = authors.getBuckets();
|
List<? extends Bucket> testBuckets = authors.getBuckets();
|
||||||
|
|
||||||
|
@ -160,7 +159,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
Terms genres = response.getAggregations().get("genres");
|
Terms genres = response.getAggregations().get("genres");
|
||||||
List<? extends Bucket> genreBuckets = genres.getBuckets();
|
List<? extends Bucket> genreBuckets = genres.getBuckets();
|
||||||
for (Terms.Bucket genreBucket : genreBuckets) {
|
for (Terms.Bucket genreBucket : genreBuckets) {
|
||||||
Sampler sample = genreBucket.getAggregations().get("sample");
|
SingleBucketAggregation sample = genreBucket.getAggregations().get("sample");
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
List<? extends Bucket> testBuckets = authors.getBuckets();
|
List<? extends Bucket> testBuckets = authors.getBuckets();
|
||||||
|
|
||||||
|
@ -189,8 +188,8 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch("test").setSearchType(SearchType.QUERY_THEN_FETCH).addAggregation(rootSample),
|
prepareSearch("test").setSearchType(SearchType.QUERY_THEN_FETCH).addAggregation(rootSample),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler genreSample = response.getAggregations().get("genreSample");
|
SingleBucketAggregation genreSample = response.getAggregations().get("genreSample");
|
||||||
Sampler sample = genreSample.getAggregations().get("sample");
|
SingleBucketAggregation sample = genreSample.getAggregations().get("sample");
|
||||||
|
|
||||||
Terms genres = sample.getAggregations().get("genres");
|
Terms genres = sample.getAggregations().get("genres");
|
||||||
List<? extends Bucket> testBuckets = genres.getBuckets();
|
List<? extends Bucket> testBuckets = genres.getBuckets();
|
||||||
|
@ -221,7 +220,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
assertThat(sample.getDocCount(), greaterThan(0L));
|
assertThat(sample.getDocCount(), greaterThan(0L));
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
assertThat(authors.getBuckets().size(), greaterThan(0));
|
assertThat(authors.getBuckets().size(), greaterThan(0));
|
||||||
|
@ -242,7 +241,7 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
assertThat(sample.getDocCount(), equalTo(0L));
|
assertThat(sample.getDocCount(), equalTo(0L));
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
assertNull(authors);
|
assertNull(authors);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||||
|
@ -584,7 +583,7 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "0.0" : "1.0"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "0.0" : "1.0"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
Filter filter = tag.getAggregations().get("filter");
|
SingleBucketAggregation filter = tag.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
|
|
||||||
|
@ -627,10 +626,10 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "1.0" : "0.0"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "1.0" : "0.0"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter1 = tag.getAggregations().get("filter1");
|
SingleBucketAggregation filter1 = tag.getAggregations().get("filter1");
|
||||||
assertThat(filter1, notNullValue());
|
assertThat(filter1, notNullValue());
|
||||||
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter2 = filter1.getAggregations().get("filter2");
|
SingleBucketAggregation filter2 = filter1.getAggregations().get("filter2");
|
||||||
assertThat(filter2, notNullValue());
|
assertThat(filter2, notNullValue());
|
||||||
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Max max = filter2.getAggregations().get("max");
|
Max max = filter2.getAggregations().get("max");
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Avg;
|
import org.elasticsearch.search.aggregations.metrics.Avg;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -77,7 +76,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
assertNoFailuresAndResponse(prepareSearch("idx").addAggregation(filter("tag1", termQuery("tag", "tag1"))), response -> {
|
assertNoFailuresAndResponse(prepareSearch("idx").addAggregation(filter("tag1", termQuery("tag", "tag1"))), response -> {
|
||||||
Filter filter = response.getAggregations().get("tag1");
|
SingleBucketAggregation filter = response.getAggregations().get("tag1");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getName(), equalTo("tag1"));
|
assertThat(filter.getName(), equalTo("tag1"));
|
||||||
assertThat(filter.getDocCount(), equalTo((long) numTag1Docs));
|
assertThat(filter.getDocCount(), equalTo((long) numTag1Docs));
|
||||||
|
@ -89,7 +88,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||||
public void testEmptyFilterDeclarations() throws Exception {
|
public void testEmptyFilterDeclarations() throws Exception {
|
||||||
QueryBuilder emptyFilter = new BoolQueryBuilder();
|
QueryBuilder emptyFilter = new BoolQueryBuilder();
|
||||||
assertNoFailuresAndResponse(prepareSearch("idx").addAggregation(filter("tag1", emptyFilter)), response -> {
|
assertNoFailuresAndResponse(prepareSearch("idx").addAggregation(filter("tag1", emptyFilter)), response -> {
|
||||||
Filter filter = response.getAggregations().get("tag1");
|
SingleBucketAggregation filter = response.getAggregations().get("tag1");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo((long) numDocs));
|
assertThat(filter.getDocCount(), equalTo((long) numDocs));
|
||||||
});
|
});
|
||||||
|
@ -99,7 +98,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch("idx").addAggregation(filter("tag1", termQuery("tag", "tag1")).subAggregation(avg("avg_value").field("value"))),
|
prepareSearch("idx").addAggregation(filter("tag1", termQuery("tag", "tag1")).subAggregation(avg("avg_value").field("value"))),
|
||||||
response -> {
|
response -> {
|
||||||
Filter filter = response.getAggregations().get("tag1");
|
SingleBucketAggregation filter = response.getAggregations().get("tag1");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getName(), equalTo("tag1"));
|
assertThat(filter.getName(), equalTo("tag1"));
|
||||||
assertThat(filter.getDocCount(), equalTo((long) numTag1Docs));
|
assertThat(filter.getDocCount(), equalTo((long) numTag1Docs));
|
||||||
|
@ -130,7 +129,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||||
assertThat(histo.getBuckets().size(), greaterThanOrEqualTo(1));
|
assertThat(histo.getBuckets().size(), greaterThanOrEqualTo(1));
|
||||||
|
|
||||||
for (Histogram.Bucket bucket : histo.getBuckets()) {
|
for (Histogram.Bucket bucket : histo.getBuckets()) {
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertEquals(bucket.getDocCount(), filter.getDocCount());
|
assertEquals(bucket.getDocCount(), filter.getDocCount());
|
||||||
}
|
}
|
||||||
|
@ -165,7 +164,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||||
Histogram.Bucket bucket = histo.getBuckets().get(1);
|
Histogram.Bucket bucket = histo.getBuckets().get(1);
|
||||||
assertThat(bucket, Matchers.notNullValue());
|
assertThat(bucket, Matchers.notNullValue());
|
||||||
|
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, Matchers.notNullValue());
|
assertThat(filter, Matchers.notNullValue());
|
||||||
assertThat(filter.getName(), equalTo("filter"));
|
assertThat(filter.getName(), equalTo("filter"));
|
||||||
assertThat(filter.getDocCount(), is(0L));
|
assertThat(filter.getDocCount(), is(0L));
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.elasticsearch.index.IndexVersion;
|
||||||
import org.elasticsearch.index.query.GeoBoundingBoxQueryBuilder;
|
import org.elasticsearch.index.query.GeoBoundingBoxQueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid;
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid.Bucket;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -186,7 +185,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
|
||||||
.subAggregation(geohashGrid("geohashgrid").field("location").precision(precision))
|
.subAggregation(geohashGrid("geohashgrid").field("location").precision(precision))
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Filter filter = response.getAggregations().get("filtered");
|
SingleBucketAggregation filter = response.getAggregations().get("filtered");
|
||||||
|
|
||||||
GeoGrid geoGrid = filter.getAggregations().get("geohashgrid");
|
GeoGrid geoGrid = filter.getAggregations().get("geohashgrid");
|
||||||
for (GeoGrid.Bucket cell : geoGrid.getBuckets()) {
|
for (GeoGrid.Bucket cell : geoGrid.getBuckets()) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.Stats;
|
import org.elasticsearch.search.aggregations.metrics.Stats;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ public class GlobalIT extends ESIntegTestCase {
|
||||||
prepareSearch("idx").setQuery(QueryBuilders.termQuery("tag", "tag1"))
|
prepareSearch("idx").setQuery(QueryBuilders.termQuery("tag", "tag1"))
|
||||||
.addAggregation(global("global").subAggregation(stats("value_stats").field("value"))),
|
.addAggregation(global("global").subAggregation(stats("value_stats").field("value"))),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DoubleBounds;
|
import org.elasticsearch.search.aggregations.bucket.histogram.DoubleBounds;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Avg;
|
import org.elasticsearch.search.aggregations.metrics.Avg;
|
||||||
|
@ -620,7 +619,7 @@ public class HistogramIT extends ESIntegTestCase {
|
||||||
int b = (int) (key / interval);
|
int b = (int) (key / interval);
|
||||||
assertThat(bucket.getDocCount(), equalTo(valueCounts[b]));
|
assertThat(bucket.getDocCount(), equalTo(valueCounts[b]));
|
||||||
assertThat(bucket.getAggregations().asList().isEmpty(), is(false));
|
assertThat(bucket.getAggregations().asList().isEmpty(), is(false));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(bucket.getDocCount(), equalTo(filter.getDocCount()));
|
assertThat(bucket.getDocCount(), equalTo(filter.getDocCount()));
|
||||||
Max max = filter.getAggregations().get("max");
|
Max max = filter.getAggregations().get("max");
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
||||||
|
@ -581,7 +580,7 @@ public class LongTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "0" : "1"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "0" : "1"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
Filter filter = tag.getAggregations().get("filter");
|
SingleBucketAggregation filter = tag.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
|
|
||||||
|
@ -624,10 +623,10 @@ public class LongTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "1" : "0"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "1" : "0"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter1 = tag.getAggregations().get("filter1");
|
SingleBucketAggregation filter1 = tag.getAggregations().get("filter1");
|
||||||
assertThat(filter1, notNullValue());
|
assertThat(filter1, notNullValue());
|
||||||
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter2 = filter1.getAggregations().get("filter2");
|
SingleBucketAggregation filter2 = filter1.getAggregations().get("filter2");
|
||||||
assertThat(filter2, notNullValue());
|
assertThat(filter2, notNullValue());
|
||||||
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Max max = filter2.getAggregations().get("max");
|
Max max = filter2.getAggregations().get("max");
|
||||||
|
|
|
@ -18,10 +18,8 @@ import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.InternalNested;
|
import org.elasticsearch.search.aggregations.bucket.nested.InternalNested;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
||||||
|
@ -203,7 +201,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Nested nested = response.getAggregations().get("nested");
|
SingleBucketAggregation nested = response.getAggregations().get("nested");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested"));
|
assertThat(nested.getName(), equalTo("nested"));
|
||||||
assertThat(nested.getDocCount(), equalTo(count));
|
assertThat(nested.getDocCount(), equalTo(count));
|
||||||
|
@ -226,7 +224,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
nested("nested", "value").subAggregation(stats("nested_value_stats").field("nested.value"))
|
nested("nested", "value").subAggregation(stats("nested_value_stats").field("nested.value"))
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested");
|
SingleBucketAggregation nested = response.getAggregations().get("nested");
|
||||||
assertThat(nested, Matchers.notNullValue());
|
assertThat(nested, Matchers.notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested"));
|
assertThat(nested.getName(), equalTo("nested"));
|
||||||
assertThat(nested.getDocCount(), is(0L));
|
assertThat(nested.getDocCount(), is(0L));
|
||||||
|
@ -256,7 +254,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Nested nested = response.getAggregations().get("nested");
|
SingleBucketAggregation nested = response.getAggregations().get("nested");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested"));
|
assertThat(nested.getName(), equalTo("nested"));
|
||||||
assertThat(nested.getDocCount(), equalTo(docCount));
|
assertThat(nested.getDocCount(), equalTo(docCount));
|
||||||
|
@ -301,7 +299,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
for (int i = 0; i < numParents; i++) {
|
for (int i = 0; i < numParents; i++) {
|
||||||
String topValue = "" + (i + 1);
|
String topValue = "" + (i + 1);
|
||||||
assertThat(values.getBucketByKey(topValue), notNullValue());
|
assertThat(values.getBucketByKey(topValue), notNullValue());
|
||||||
Nested nested = values.getBucketByKey(topValue).getAggregations().get("nested");
|
SingleBucketAggregation nested = values.getBucketByKey(topValue).getAggregations().get("nested");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
Max max = nested.getAggregations().get("max_value");
|
Max max = nested.getAggregations().get("max_value");
|
||||||
assertThat(max, notNullValue());
|
assertThat(max, notNullValue());
|
||||||
|
@ -321,7 +319,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested level1 = response.getAggregations().get("level1");
|
SingleBucketAggregation level1 = response.getAggregations().get("level1");
|
||||||
assertThat(level1, notNullValue());
|
assertThat(level1, notNullValue());
|
||||||
assertThat(level1.getName(), equalTo("level1"));
|
assertThat(level1.getName(), equalTo("level1"));
|
||||||
assertThat(level1.getDocCount(), equalTo(2L));
|
assertThat(level1.getDocCount(), equalTo(2L));
|
||||||
|
@ -330,7 +328,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
Terms.Bucket bBucket = a.getBucketByKey("a");
|
Terms.Bucket bBucket = a.getBucketByKey("a");
|
||||||
assertThat(bBucket.getDocCount(), equalTo(1L));
|
assertThat(bBucket.getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
Nested level2 = bBucket.getAggregations().get("level2");
|
SingleBucketAggregation level2 = bBucket.getAggregations().get("level2");
|
||||||
assertThat(level2.getDocCount(), equalTo(1L));
|
assertThat(level2.getDocCount(), equalTo(1L));
|
||||||
Sum sum = level2.getAggregations().get("sum");
|
Sum sum = level2.getAggregations().get("sum");
|
||||||
assertThat(sum.value(), equalTo(2d));
|
assertThat(sum.value(), equalTo(2d));
|
||||||
|
@ -358,7 +356,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
Histogram.Bucket bucket = histo.getBuckets().get(1);
|
Histogram.Bucket bucket = histo.getBuckets().get(1);
|
||||||
assertThat(bucket, Matchers.notNullValue());
|
assertThat(bucket, Matchers.notNullValue());
|
||||||
|
|
||||||
Nested nested = bucket.getAggregations().get("nested");
|
SingleBucketAggregation nested = bucket.getAggregations().get("nested");
|
||||||
assertThat(nested, Matchers.notNullValue());
|
assertThat(nested, Matchers.notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested"));
|
assertThat(nested.getName(), equalTo("nested"));
|
||||||
assertThat(nested.getDocCount(), is(0L));
|
assertThat(nested.getDocCount(), is(0L));
|
||||||
|
@ -517,11 +515,11 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
Terms period = bucket.getAggregations().get("period");
|
Terms period = bucket.getAggregations().get("period");
|
||||||
bucket = period.getBucketByKey("2014-11");
|
bucket = period.getBucketByKey("2014-11");
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Nested comments = bucket.getAggregations().get("ctxt_idfier_nested");
|
SingleBucketAggregation comments = bucket.getAggregations().get("ctxt_idfier_nested");
|
||||||
assertThat(comments.getDocCount(), equalTo(2L));
|
assertThat(comments.getDocCount(), equalTo(2L));
|
||||||
Filter filter = comments.getAggregations().get("comment_filter");
|
SingleBucketAggregation filter = comments.getAggregations().get("comment_filter");
|
||||||
assertThat(filter.getDocCount(), equalTo(1L));
|
assertThat(filter.getDocCount(), equalTo(1L));
|
||||||
Nested nestedTags = filter.getAggregations().get("nested_tags");
|
SingleBucketAggregation nestedTags = filter.getAggregations().get("nested_tags");
|
||||||
assertThat(nestedTags.getDocCount(), equalTo(0L)); // This must be 0
|
assertThat(nestedTags.getDocCount(), equalTo(0L)); // This must be 0
|
||||||
Terms tags = nestedTags.getAggregations().get("tag");
|
Terms tags = nestedTags.getAggregations().get("tag");
|
||||||
assertThat(tags.getBuckets().size(), equalTo(0)); // and this must be empty
|
assertThat(tags.getBuckets().size(), equalTo(0)); // and this must be empty
|
||||||
|
@ -606,7 +604,7 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
|
|
||||||
Terms.Bucket bucket = category.getBucketByKey("1");
|
Terms.Bucket bucket = category.getBucketByKey("1");
|
||||||
assertThat(bucket.getDocCount(), equalTo(2L));
|
assertThat(bucket.getDocCount(), equalTo(2L));
|
||||||
Nested property = bucket.getAggregations().get("property");
|
SingleBucketAggregation property = bucket.getAggregations().get("property");
|
||||||
assertThat(property.getDocCount(), equalTo(6L));
|
assertThat(property.getDocCount(), equalTo(6L));
|
||||||
Terms propertyId = property.getAggregations().get("property_id");
|
Terms propertyId = property.getAggregations().get("property_id");
|
||||||
assertThat(propertyId.getBuckets().size(), equalTo(5));
|
assertThat(propertyId.getBuckets().size(), equalTo(5));
|
||||||
|
@ -778,8 +776,8 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested toMethods = response.getAggregations().get("to_method");
|
SingleBucketAggregation toMethods = response.getAggregations().get("to_method");
|
||||||
Filter numStringParams = toMethods.getAggregations().get("num_string_params");
|
SingleBucketAggregation numStringParams = toMethods.getAggregations().get("num_string_params");
|
||||||
assertThat(numStringParams.getDocCount(), equalTo(3L));
|
assertThat(numStringParams.getDocCount(), equalTo(3L));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -796,11 +794,11 @@ public class NestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested toMethods = response.getAggregations().get("to_method");
|
SingleBucketAggregation toMethods = response.getAggregations().get("to_method");
|
||||||
Terms terms = toMethods.getAggregations().get("return_type");
|
Terms terms = toMethods.getAggregations().get("return_type");
|
||||||
Bucket bucket = terms.getBucketByKey("void");
|
Bucket bucket = terms.getBucketByKey("void");
|
||||||
assertThat(bucket.getDocCount(), equalTo(3L));
|
assertThat(bucket.getDocCount(), equalTo(3L));
|
||||||
Filter numStringParams = bucket.getAggregations().get("num_string_params");
|
SingleBucketAggregation numStringParams = bucket.getAggregations().get("num_string_params");
|
||||||
assertThat(numStringParams.getDocCount(), equalTo(2L));
|
assertThat(numStringParams.getDocCount(), equalTo(2L));
|
||||||
|
|
||||||
bucket = terms.getBucketByKey("QueryBuilder");
|
bucket = terms.getBucketByKey("QueryBuilder");
|
||||||
|
|
|
@ -12,9 +12,6 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.metrics.ValueCount;
|
import org.elasticsearch.search.aggregations.metrics.ValueCount;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -155,7 +152,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested1");
|
SingleBucketAggregation nested = response.getAggregations().get("nested1");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested1"));
|
assertThat(nested.getName(), equalTo("nested1"));
|
||||||
assertThat(nested.getDocCount(), equalTo(25L));
|
assertThat(nested.getDocCount(), equalTo(25L));
|
||||||
|
@ -170,7 +167,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
Terms.Bucket bucket = usernameBuckets.get(0);
|
Terms.Bucket bucket = usernameBuckets.get(0);
|
||||||
assertThat(bucket.getKeyAsString(), equalTo("1"));
|
assertThat(bucket.getKeyAsString(), equalTo("1"));
|
||||||
assertThat(bucket.getDocCount(), equalTo(6L));
|
assertThat(bucket.getDocCount(), equalTo(6L));
|
||||||
ReverseNested reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
SingleBucketAggregation reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
||||||
assertThat(((InternalAggregation) reverseNested).getProperty("_count"), equalTo(5L));
|
assertThat(((InternalAggregation) reverseNested).getProperty("_count"), equalTo(5L));
|
||||||
Terms tags = reverseNested.getAggregations().get("field1");
|
Terms tags = reverseNested.getAggregations().get("field1");
|
||||||
assertThat(((InternalAggregation) reverseNested).getProperty("field1"), sameInstance(tags));
|
assertThat(((InternalAggregation) reverseNested).getProperty("field1"), sameInstance(tags));
|
||||||
|
@ -336,10 +333,10 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested1");
|
SingleBucketAggregation nested = response.getAggregations().get("nested1");
|
||||||
assertThat(nested.getName(), equalTo("nested1"));
|
assertThat(nested.getName(), equalTo("nested1"));
|
||||||
assertThat(nested.getDocCount(), equalTo(9L));
|
assertThat(nested.getDocCount(), equalTo(9L));
|
||||||
ReverseNested reverseNested = nested.getAggregations().get("nested1_to_root");
|
SingleBucketAggregation reverseNested = nested.getAggregations().get("nested1_to_root");
|
||||||
assertThat(reverseNested.getName(), equalTo("nested1_to_root"));
|
assertThat(reverseNested.getName(), equalTo("nested1_to_root"));
|
||||||
assertThat(reverseNested.getDocCount(), equalTo(4L));
|
assertThat(reverseNested.getDocCount(), equalTo(4L));
|
||||||
nested = reverseNested.getAggregations().get("root_to_nested2");
|
nested = reverseNested.getAggregations().get("root_to_nested2");
|
||||||
|
@ -368,7 +365,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested1");
|
SingleBucketAggregation nested = response.getAggregations().get("nested1");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested1"));
|
assertThat(nested.getName(), equalTo("nested1"));
|
||||||
assertThat(nested.getDocCount(), equalTo(27L));
|
assertThat(nested.getDocCount(), equalTo(27L));
|
||||||
|
@ -382,7 +379,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
Terms.Bucket bucket = usernameBuckets.get(0);
|
Terms.Bucket bucket = usernameBuckets.get(0);
|
||||||
assertThat(bucket.getKeyAsString(), equalTo("0"));
|
assertThat(bucket.getKeyAsString(), equalTo("0"));
|
||||||
assertThat(bucket.getDocCount(), equalTo(12L));
|
assertThat(bucket.getDocCount(), equalTo(12L));
|
||||||
ReverseNested reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
SingleBucketAggregation reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
||||||
assertThat(reverseNested.getDocCount(), equalTo(5L));
|
assertThat(reverseNested.getDocCount(), equalTo(5L));
|
||||||
Terms tags = reverseNested.getAggregations().get("field1");
|
Terms tags = reverseNested.getAggregations().get("field1");
|
||||||
List<Terms.Bucket> tagsBuckets = new ArrayList<>(tags.getBuckets());
|
List<Terms.Bucket> tagsBuckets = new ArrayList<>(tags.getBuckets());
|
||||||
|
@ -476,11 +473,11 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
.addAggregation(nested("nested2", "nested1.nested2").subAggregation(reverseNested("incorrect").path("nested3"))),
|
.addAggregation(nested("nested2", "nested1.nested2").subAggregation(reverseNested("incorrect").path("nested3"))),
|
||||||
response -> {
|
response -> {
|
||||||
|
|
||||||
Nested nested = response.getAggregations().get("nested2");
|
SingleBucketAggregation nested = response.getAggregations().get("nested2");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("nested2"));
|
assertThat(nested.getName(), equalTo("nested2"));
|
||||||
|
|
||||||
ReverseNested reverseNested = nested.getAggregations().get("incorrect");
|
SingleBucketAggregation reverseNested = nested.getAggregations().get("incorrect");
|
||||||
assertThat(reverseNested.getDocCount(), is(0L));
|
assertThat(reverseNested.getDocCount(), is(0L));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -491,7 +488,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
.addAggregation(nested("incorrect1", "incorrect1").subAggregation(reverseNested("incorrect2").path("incorrect2"))),
|
.addAggregation(nested("incorrect1", "incorrect1").subAggregation(reverseNested("incorrect2").path("incorrect2"))),
|
||||||
response -> {
|
response -> {
|
||||||
|
|
||||||
Nested nested = response.getAggregations().get("incorrect1");
|
SingleBucketAggregation nested = response.getAggregations().get("incorrect1");
|
||||||
assertThat(nested, notNullValue());
|
assertThat(nested, notNullValue());
|
||||||
assertThat(nested.getName(), equalTo("incorrect1"));
|
assertThat(nested.getName(), equalTo("incorrect1"));
|
||||||
assertThat(nested.getDocCount(), is(0L));
|
assertThat(nested.getDocCount(), is(0L));
|
||||||
|
@ -630,7 +627,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
||||||
Nested nested0 = response.getAggregations().get("nested_0");
|
SingleBucketAggregation nested0 = response.getAggregations().get("nested_0");
|
||||||
assertThat(nested0.getDocCount(), equalTo(3L));
|
assertThat(nested0.getDocCount(), equalTo(3L));
|
||||||
Terms terms = nested0.getAggregations().get("group_by_category");
|
Terms terms = nested0.getAggregations().get("group_by_category");
|
||||||
assertThat(terms.getBuckets().size(), equalTo(3));
|
assertThat(terms.getBuckets().size(), equalTo(3));
|
||||||
|
@ -638,11 +635,11 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
logger.info("Checking results for bucket {}", bucketName);
|
logger.info("Checking results for bucket {}", bucketName);
|
||||||
Terms.Bucket bucket = terms.getBucketByKey(bucketName);
|
Terms.Bucket bucket = terms.getBucketByKey(bucketName);
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
ReverseNested toRoot = bucket.getAggregations().get("to_root");
|
SingleBucketAggregation toRoot = bucket.getAggregations().get("to_root");
|
||||||
assertThat(toRoot.getDocCount(), equalTo(1L));
|
assertThat(toRoot.getDocCount(), equalTo(1L));
|
||||||
Nested nested1 = toRoot.getAggregations().get("nested_1");
|
SingleBucketAggregation nested1 = toRoot.getAggregations().get("nested_1");
|
||||||
assertThat(nested1.getDocCount(), equalTo(5L));
|
assertThat(nested1.getDocCount(), equalTo(5L));
|
||||||
Filter filterByBar = nested1.getAggregations().get("filter_by_sku");
|
SingleBucketAggregation filterByBar = nested1.getAggregations().get("filter_by_sku");
|
||||||
assertThat(filterByBar.getDocCount(), equalTo(3L));
|
assertThat(filterByBar.getDocCount(), equalTo(3L));
|
||||||
ValueCount barCount = filterByBar.getAggregations().get("sku_count");
|
ValueCount barCount = filterByBar.getAggregations().get("sku_count");
|
||||||
assertThat(barCount.getValue(), equalTo(3L));
|
assertThat(barCount.getValue(), equalTo(3L));
|
||||||
|
@ -673,7 +670,7 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
||||||
Nested nested0 = response.getAggregations().get("nested_0");
|
SingleBucketAggregation nested0 = response.getAggregations().get("nested_0");
|
||||||
assertThat(nested0.getDocCount(), equalTo(3L));
|
assertThat(nested0.getDocCount(), equalTo(3L));
|
||||||
Terms terms = nested0.getAggregations().get("group_by_category");
|
Terms terms = nested0.getAggregations().get("group_by_category");
|
||||||
assertThat(terms.getBuckets().size(), equalTo(3));
|
assertThat(terms.getBuckets().size(), equalTo(3));
|
||||||
|
@ -681,17 +678,17 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
logger.info("Checking results for bucket {}", bucketName);
|
logger.info("Checking results for bucket {}", bucketName);
|
||||||
Terms.Bucket bucket = terms.getBucketByKey(bucketName);
|
Terms.Bucket bucket = terms.getBucketByKey(bucketName);
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
ReverseNested toRoot = bucket.getAggregations().get("to_root");
|
SingleBucketAggregation toRoot = bucket.getAggregations().get("to_root");
|
||||||
assertThat(toRoot.getDocCount(), equalTo(1L));
|
assertThat(toRoot.getDocCount(), equalTo(1L));
|
||||||
Nested nested1 = toRoot.getAggregations().get("nested_1");
|
SingleBucketAggregation nested1 = toRoot.getAggregations().get("nested_1");
|
||||||
assertThat(nested1.getDocCount(), equalTo(5L));
|
assertThat(nested1.getDocCount(), equalTo(5L));
|
||||||
Filter filterByBar = nested1.getAggregations().get("filter_by_sku");
|
SingleBucketAggregation filterByBar = nested1.getAggregations().get("filter_by_sku");
|
||||||
assertThat(filterByBar.getDocCount(), equalTo(3L));
|
assertThat(filterByBar.getDocCount(), equalTo(3L));
|
||||||
Nested nested2 = filterByBar.getAggregations().get("nested_2");
|
SingleBucketAggregation nested2 = filterByBar.getAggregations().get("nested_2");
|
||||||
assertThat(nested2.getDocCount(), equalTo(8L));
|
assertThat(nested2.getDocCount(), equalTo(8L));
|
||||||
Filter filterBarColor = nested2.getAggregations().get("filter_sku_color");
|
SingleBucketAggregation filterBarColor = nested2.getAggregations().get("filter_sku_color");
|
||||||
assertThat(filterBarColor.getDocCount(), equalTo(2L));
|
assertThat(filterBarColor.getDocCount(), equalTo(2L));
|
||||||
ReverseNested reverseToBar = filterBarColor.getAggregations().get("reverse_to_sku");
|
SingleBucketAggregation reverseToBar = filterBarColor.getAggregations().get("reverse_to_sku");
|
||||||
assertThat(reverseToBar.getDocCount(), equalTo(2L));
|
assertThat(reverseToBar.getDocCount(), equalTo(2L));
|
||||||
ValueCount barCount = reverseToBar.getAggregations().get("sku_count");
|
ValueCount barCount = reverseToBar.getAggregations().get("sku_count");
|
||||||
assertThat(barCount.getValue(), equalTo(2L));
|
assertThat(barCount.getValue(), equalTo(2L));
|
||||||
|
@ -713,11 +710,11 @@ public class ReverseNestedIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested1");
|
SingleBucketAggregation nested = response.getAggregations().get("nested1");
|
||||||
Terms nestedTerms = nested.getAggregations().get("field2");
|
Terms nestedTerms = nested.getAggregations().get("field2");
|
||||||
Terms.Bucket bucket = nestedTerms.getBuckets().iterator().next();
|
Terms.Bucket bucket = nestedTerms.getBuckets().iterator().next();
|
||||||
|
|
||||||
ReverseNested reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
SingleBucketAggregation reverseNested = bucket.getAggregations().get("nested1_to_field1");
|
||||||
Terms reverseNestedTerms = reverseNested.getAggregations().get("field1");
|
Terms reverseNestedTerms = reverseNested.getAggregations().get("field1");
|
||||||
|
|
||||||
assertThat(((InternalAggregation) reverseNested).getProperty("field1"), sameInstance(reverseNestedTerms));
|
assertThat(((InternalAggregation) reverseNested).getProperty("field1"), sameInstance(reverseNestedTerms));
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.Sampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregator;
|
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregator;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
@ -105,7 +104,7 @@ public class SamplerIT extends ESIntegTestCase {
|
||||||
assertThat(genreBuckets.size(), greaterThan(1));
|
assertThat(genreBuckets.size(), greaterThan(1));
|
||||||
double lastMaxPrice = asc ? Double.MIN_VALUE : Double.MAX_VALUE;
|
double lastMaxPrice = asc ? Double.MIN_VALUE : Double.MAX_VALUE;
|
||||||
for (Terms.Bucket genreBucket : genres.getBuckets()) {
|
for (Terms.Bucket genreBucket : genres.getBuckets()) {
|
||||||
Sampler sample = genreBucket.getAggregations().get("sample");
|
SingleBucketAggregation sample = genreBucket.getAggregations().get("sample");
|
||||||
Max maxPriceInGenre = sample.getAggregations().get("max_price");
|
Max maxPriceInGenre = sample.getAggregations().get("max_price");
|
||||||
double price = maxPriceInGenre.value();
|
double price = maxPriceInGenre.value();
|
||||||
if (asc) {
|
if (asc) {
|
||||||
|
@ -129,7 +128,7 @@ public class SamplerIT extends ESIntegTestCase {
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
List<? extends Bucket> testBuckets = authors.getBuckets();
|
List<? extends Bucket> testBuckets = authors.getBuckets();
|
||||||
|
|
||||||
|
@ -152,7 +151,7 @@ public class SamplerIT extends ESIntegTestCase {
|
||||||
.setSize(60)
|
.setSize(60)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
assertThat(sample.getDocCount(), equalTo(0L));
|
assertThat(sample.getDocCount(), equalTo(0L));
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
assertThat(authors.getBuckets().size(), equalTo(0));
|
assertThat(authors.getBuckets().size(), equalTo(0));
|
||||||
|
@ -171,7 +170,7 @@ public class SamplerIT extends ESIntegTestCase {
|
||||||
.setExplain(true)
|
.setExplain(true)
|
||||||
.addAggregation(sampleAgg),
|
.addAggregation(sampleAgg),
|
||||||
response -> {
|
response -> {
|
||||||
Sampler sample = response.getAggregations().get("sample");
|
SingleBucketAggregation sample = response.getAggregations().get("sample");
|
||||||
assertThat(sample.getDocCount(), greaterThan(0L));
|
assertThat(sample.getDocCount(), greaterThan(0L));
|
||||||
Terms authors = sample.getAggregations().get("authors");
|
Terms authors = sample.getAggregations().get("authors");
|
||||||
assertThat(authors.getBuckets().size(), greaterThan(0));
|
assertThat(authors.getBuckets().size(), greaterThan(0));
|
||||||
|
|
|
@ -12,13 +12,9 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.geometry.utils.Geohash;
|
import org.elasticsearch.geometry.utils.Geohash;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoGrid;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -94,7 +90,7 @@ public class ShardReduceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
Histogram histo = global.getAggregations().get("histo");
|
Histogram histo = global.getAggregations().get("histo");
|
||||||
assertThat(histo.getBuckets().size(), equalTo(4));
|
assertThat(histo.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +106,7 @@ public class ShardReduceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Filter filter = response.getAggregations().get("filter");
|
SingleBucketAggregation filter = response.getAggregations().get("filter");
|
||||||
Histogram histo = filter.getAggregations().get("histo");
|
Histogram histo = filter.getAggregations().get("histo");
|
||||||
assertThat(histo.getBuckets().size(), equalTo(4));
|
assertThat(histo.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
@ -125,7 +121,7 @@ public class ShardReduceIT extends ESIntegTestCase {
|
||||||
.subAggregation(dateHistogram("histo").field("date").fixedInterval(DateHistogramInterval.DAY).minDocCount(0))
|
.subAggregation(dateHistogram("histo").field("date").fixedInterval(DateHistogramInterval.DAY).minDocCount(0))
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Missing missing = response.getAggregations().get("missing");
|
SingleBucketAggregation missing = response.getAggregations().get("missing");
|
||||||
Histogram histo = missing.getAggregations().get("histo");
|
Histogram histo = missing.getAggregations().get("histo");
|
||||||
assertThat(histo.getBuckets().size(), equalTo(4));
|
assertThat(histo.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
@ -146,9 +142,9 @@ public class ShardReduceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
Filter filter = global.getAggregations().get("filter");
|
SingleBucketAggregation filter = global.getAggregations().get("filter");
|
||||||
Missing missing = filter.getAggregations().get("missing");
|
SingleBucketAggregation missing = filter.getAggregations().get("missing");
|
||||||
Histogram histo = missing.getAggregations().get("histo");
|
Histogram histo = missing.getAggregations().get("histo");
|
||||||
assertThat(histo.getBuckets().size(), equalTo(4));
|
assertThat(histo.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
@ -164,7 +160,7 @@ public class ShardReduceIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("nested");
|
SingleBucketAggregation nested = response.getAggregations().get("nested");
|
||||||
Histogram histo = nested.getAggregations().get("histo");
|
Histogram histo = nested.getAggregations().get("histo");
|
||||||
assertThat(histo.getBuckets().size(), equalTo(4));
|
assertThat(histo.getBuckets().size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
|
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.AbstractTermsTestCase;
|
import org.elasticsearch.search.aggregations.bucket.AbstractTermsTestCase;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Avg;
|
import org.elasticsearch.search.aggregations.metrics.Avg;
|
||||||
|
@ -599,7 +599,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertThat(response.getFailedShards(), equalTo(0));
|
assertThat(response.getFailedShards(), equalTo(0));
|
||||||
|
|
||||||
Filter filter = response.getAggregations().get("filter");
|
SingleBucketAggregation filter = response.getAggregations().get("filter");
|
||||||
|
|
||||||
StringTerms terms = filter.getAggregations().get("terms");
|
StringTerms terms = filter.getAggregations().get("terms");
|
||||||
assertThat(terms, notNullValue());
|
assertThat(terms, notNullValue());
|
||||||
|
@ -672,7 +672,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "less" : "more"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "less" : "more"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
Filter filter = tag.getAggregations().get("filter");
|
SingleBucketAggregation filter = tag.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L));
|
||||||
|
|
||||||
|
@ -716,10 +716,10 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter1 = tag.getAggregations().get("filter1");
|
SingleBucketAggregation filter1 = tag.getAggregations().get("filter1");
|
||||||
assertThat(filter1, notNullValue());
|
assertThat(filter1, notNullValue());
|
||||||
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter2 = filter1.getAggregations().get("filter2");
|
SingleBucketAggregation filter2 = filter1.getAggregations().get("filter2");
|
||||||
assertThat(filter2, notNullValue());
|
assertThat(filter2, notNullValue());
|
||||||
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Stats stats = filter2.getAggregations().get("stats");
|
Stats stats = filter2.getAggregations().get("stats");
|
||||||
|
@ -778,10 +778,10 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter1 = tag.getAggregations().get("filter1");
|
SingleBucketAggregation filter1 = tag.getAggregations().get("filter1");
|
||||||
assertThat(filter1, notNullValue());
|
assertThat(filter1, notNullValue());
|
||||||
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter2 = filter1.getAggregations().get(filter2Name);
|
SingleBucketAggregation filter2 = filter1.getAggregations().get(filter2Name);
|
||||||
assertThat(filter2, notNullValue());
|
assertThat(filter2, notNullValue());
|
||||||
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Stats stats = filter2.getAggregations().get(statsName);
|
Stats stats = filter2.getAggregations().get(statsName);
|
||||||
|
@ -840,10 +840,10 @@ public class StringTermsIT extends AbstractTermsTestCase {
|
||||||
assertThat(tag, notNullValue());
|
assertThat(tag, notNullValue());
|
||||||
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
assertThat(tag.getKeyAsString(), equalTo(asc ? "more" : "less"));
|
||||||
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter1 = tag.getAggregations().get("filter1");
|
SingleBucketAggregation filter1 = tag.getAggregations().get("filter1");
|
||||||
assertThat(filter1, notNullValue());
|
assertThat(filter1, notNullValue());
|
||||||
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Filter filter2 = filter1.getAggregations().get(filter2Name);
|
SingleBucketAggregation filter2 = filter1.getAggregations().get(filter2Name);
|
||||||
assertThat(filter2, notNullValue());
|
assertThat(filter2, notNullValue());
|
||||||
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L));
|
||||||
Stats stats = filter2.getAggregations().get(statsName);
|
Stats stats = filter2.getAggregations().get(statsName);
|
||||||
|
|
|
@ -14,10 +14,8 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.metrics.ExtendedStats.Bounds;
|
import org.elasticsearch.search.aggregations.metrics.ExtendedStats.Bounds;
|
||||||
|
|
||||||
|
@ -285,7 +283,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -804,7 +802,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
|
||||||
for (Terms.Bucket bucket : terms.getBuckets()) {
|
for (Terms.Bucket bucket : terms.getBuckets()) {
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
|
|
||||||
Missing missing = bucket.getAggregations().get("values");
|
SingleBucketAggregation missing = bucket.getAggregations().get("values");
|
||||||
assertThat(missing, notNullValue());
|
assertThat(missing, notNullValue());
|
||||||
assertThat(missing.getDocCount(), equalTo(0L));
|
assertThat(missing.getDocCount(), equalTo(0L));
|
||||||
|
|
||||||
|
@ -856,7 +854,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
ExtendedStats extendedStats = filter.getAggregations().get("extendedStats");
|
ExtendedStats extendedStats = filter.getAggregations().get("extendedStats");
|
||||||
|
|
|
@ -15,8 +15,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
|
@ -217,7 +216,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -550,7 +549,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
PercentileRanks ranks = filter.getAggregations().get("ranks");
|
PercentileRanks ranks = filter.getAggregations().get("ranks");
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
|
@ -194,7 +193,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -523,7 +522,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
Percentiles percentiles = filter.getAggregations().get("percentiles");
|
Percentiles percentiles = filter.getAggregations().get("percentiles");
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
@ -180,7 +179,7 @@ public class MedianAbsoluteDeviationIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, NUMBER_OF_DOCS);
|
assertHitCount(response, NUMBER_OF_DOCS);
|
||||||
|
|
||||||
final Global global = response.getAggregations().get("global");
|
final SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), is("global"));
|
assertThat(global.getName(), is("global"));
|
||||||
assertThat(global.getDocCount(), is((long) NUMBER_OF_DOCS));
|
assertThat(global.getDocCount(), is((long) NUMBER_OF_DOCS));
|
||||||
|
@ -476,7 +475,7 @@ public class MedianAbsoluteDeviationIT extends AbstractNumericTestCase {
|
||||||
Terms.Bucket bucket = buckets.get(i);
|
Terms.Bucket bucket = buckets.get(i);
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
|
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
|
@ -713,7 +713,7 @@ public class ScriptedMetricIT extends ESIntegTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertThat(response.getHits().getTotalHits().value(), equalTo(numDocs));
|
assertThat(response.getHits().getTotalHits().value(), equalTo(numDocs));
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(numDocs));
|
assertThat(global.getDocCount(), equalTo(numDocs));
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ public class StatsIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -201,7 +200,7 @@ public class StatsIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
Stats stats = filter.getAggregations().get("stats");
|
Stats stats = filter.getAggregations().get("stats");
|
||||||
|
|
|
@ -14,8 +14,7 @@ import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.hamcrest.core.IsNull;
|
import org.hamcrest.core.IsNull;
|
||||||
|
@ -135,7 +134,7 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -190,7 +189,7 @@ public class SumIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
Sum sum = filter.getAggregations().get("sum");
|
Sum sum = filter.getAggregations().get("sum");
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -467,7 +466,7 @@ public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
PercentileRanks ranks = filter.getAggregations().get("ranks");
|
PercentileRanks ranks = filter.getAggregations().get("ranks");
|
||||||
|
|
|
@ -16,8 +16,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
|
|
||||||
|
@ -171,7 +170,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -440,7 +439,7 @@ public class TDigestPercentilesIT extends AbstractNumericTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
Percentiles percentiles = filter.getAggregations().get("percentiles");
|
Percentiles percentiles = filter.getAggregations().get("percentiles");
|
||||||
|
|
|
@ -33,9 +33,8 @@ import org.elasticsearch.search.SearchHits;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode;
|
||||||
import org.elasticsearch.search.fetch.FetchSubPhase;
|
import org.elasticsearch.search.fetch.FetchSubPhase;
|
||||||
|
@ -465,7 +464,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
assertNoFailuresAndResponse(
|
assertNoFailuresAndResponse(
|
||||||
prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(global("global").subAggregation(topHits("hits"))),
|
prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(global("global").subAggregation(topHits("hits"))),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getAggregations(), notNullValue());
|
assertThat(global.getAggregations(), notNullValue());
|
||||||
|
@ -744,7 +743,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested nested = response.getAggregations().get("to-comments");
|
SingleBucketAggregation nested = response.getAggregations().get("to-comments");
|
||||||
assertThat(nested.getDocCount(), equalTo(4L));
|
assertThat(nested.getDocCount(), equalTo(4L));
|
||||||
|
|
||||||
Terms terms = nested.getAggregations().get("users");
|
Terms terms = nested.getAggregations().get("users");
|
||||||
|
@ -793,7 +792,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
).subAggregation(topHits("top-comments").sort("comments.date", SortOrder.DESC).size(4))
|
).subAggregation(topHits("top-comments").sort("comments.date", SortOrder.DESC).size(4))
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
Nested toComments = response.getAggregations().get("to-comments");
|
SingleBucketAggregation toComments = response.getAggregations().get("to-comments");
|
||||||
assertThat(toComments.getDocCount(), equalTo(4L));
|
assertThat(toComments.getDocCount(), equalTo(4L));
|
||||||
|
|
||||||
TopHits topComments = toComments.getAggregations().get("top-comments");
|
TopHits topComments = toComments.getAggregations().get("top-comments");
|
||||||
|
@ -820,7 +819,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
assertThat(topComments.getHits().getAt(3).getNestedIdentity().getOffset(), equalTo(0));
|
assertThat(topComments.getHits().getAt(3).getNestedIdentity().getOffset(), equalTo(0));
|
||||||
assertThat(topComments.getHits().getAt(3).getNestedIdentity().getChild(), nullValue());
|
assertThat(topComments.getHits().getAt(3).getNestedIdentity().getChild(), nullValue());
|
||||||
|
|
||||||
Nested toReviewers = toComments.getAggregations().get("to-reviewers");
|
SingleBucketAggregation toReviewers = toComments.getAggregations().get("to-reviewers");
|
||||||
assertThat(toReviewers.getDocCount(), equalTo(7L));
|
assertThat(toReviewers.getDocCount(), equalTo(7L));
|
||||||
|
|
||||||
TopHits topReviewers = toReviewers.getAggregations().get("top-reviewers");
|
TopHits topReviewers = toReviewers.getAggregations().get("top-reviewers");
|
||||||
|
@ -903,7 +902,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
),
|
),
|
||||||
response -> {
|
response -> {
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
Nested nested = response.getAggregations().get("to-comments");
|
SingleBucketAggregation nested = response.getAggregations().get("to-comments");
|
||||||
assertThat(nested.getDocCount(), equalTo(4L));
|
assertThat(nested.getDocCount(), equalTo(4L));
|
||||||
|
|
||||||
SearchHits hits = ((TopHits) nested.getAggregations().get("top-comments")).getHits();
|
SearchHits hits = ((TopHits) nested.getAggregations().get("top-comments")).getHits();
|
||||||
|
@ -964,7 +963,7 @@ public class TopHitsIT extends ESIntegTestCase {
|
||||||
assertThat(bucket.getDocCount(), equalTo(5L));
|
assertThat(bucket.getDocCount(), equalTo(5L));
|
||||||
|
|
||||||
long numNestedDocs = 10 + (5 * i);
|
long numNestedDocs = 10 + (5 * i);
|
||||||
Nested nested = bucket.getAggregations().get("to-comments");
|
SingleBucketAggregation nested = bucket.getAggregations().get("to-comments");
|
||||||
assertThat(nested.getDocCount(), equalTo(numNestedDocs));
|
assertThat(nested.getDocCount(), equalTo(numNestedDocs));
|
||||||
|
|
||||||
TopHits hits = nested.getAggregations().get("comments");
|
TopHits hits = nested.getAggregations().get("comments");
|
||||||
|
|
|
@ -13,8 +13,7 @@ import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
|
||||||
|
@ -94,7 +93,7 @@ public class ValueCountIT extends ESIntegTestCase {
|
||||||
|
|
||||||
assertHitCount(response, 10);
|
assertHitCount(response, 10);
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo(10L));
|
assertThat(global.getDocCount(), equalTo(10L));
|
||||||
|
@ -304,7 +303,7 @@ public class ValueCountIT extends ESIntegTestCase {
|
||||||
assertThat(bucket, notNullValue());
|
assertThat(bucket, notNullValue());
|
||||||
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
assertThat(bucket.getKeyAsNumber(), equalTo((long) i + 1));
|
||||||
assertThat(bucket.getDocCount(), equalTo(1L));
|
assertThat(bucket.getDocCount(), equalTo(1L));
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertThat(filter, notNullValue());
|
assertThat(filter, notNullValue());
|
||||||
assertThat(filter.getDocCount(), equalTo(0L));
|
assertThat(filter.getDocCount(), equalTo(0L));
|
||||||
ValueCount count = filter.getAggregations().get("count");
|
ValueCount count = filter.getAggregations().get("count");
|
||||||
|
|
|
@ -24,8 +24,7 @@ import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -303,9 +302,9 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase {
|
||||||
assertNoFailuresAndResponse(client().search(new SearchRequest("test").source(sourceBuilder)), response -> {
|
assertNoFailuresAndResponse(client().search(new SearchRequest("test").source(sourceBuilder)), response -> {
|
||||||
assertThat(response.getHits().getTotalHits().value(), equalTo(100L));
|
assertThat(response.getHits().getTotalHits().value(), equalTo(100L));
|
||||||
|
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
Filter all = global.getAggregations().get("all");
|
SingleBucketAggregation all = global.getAggregations().get("all");
|
||||||
Filter test1 = response.getAggregations().get("test1");
|
SingleBucketAggregation test1 = response.getAggregations().get("test1");
|
||||||
assertThat(test1.getDocCount(), equalTo(1L));
|
assertThat(test1.getDocCount(), equalTo(1L));
|
||||||
assertThat(all.getDocCount(), equalTo(100L));
|
assertThat(all.getDocCount(), equalTo(100L));
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,9 +11,9 @@ package org.elasticsearch.search.aggregations;
|
||||||
import org.elasticsearch.common.geo.GeoDistance;
|
import org.elasticsearch.common.geo.GeoDistance;
|
||||||
import org.elasticsearch.common.geo.GeoPoint;
|
import org.elasticsearch.common.geo.GeoPoint;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
|
import org.elasticsearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filters;
|
import org.elasticsearch.search.aggregations.bucket.filter.Filters;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FiltersAggregationBuilder;
|
||||||
|
@ -22,16 +22,12 @@ import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridAggregati
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileGridAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileGridAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid;
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoTileGrid;
|
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoTileGrid;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.MissingAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.missing.MissingAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.GeoDistanceAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.range.GeoDistanceAggregationBuilder;
|
||||||
|
@ -39,7 +35,6 @@ import org.elasticsearch.search.aggregations.bucket.range.IpRangeAggregationBuil
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.Sampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTermsAggregationBuilder;
|
||||||
|
@ -136,7 +131,7 @@ public class AggregationBuilders {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Filter} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static FilterAggregationBuilder filter(String name, QueryBuilder filter) {
|
public static FilterAggregationBuilder filter(String name, QueryBuilder filter) {
|
||||||
return new FilterAggregationBuilder(name, filter);
|
return new FilterAggregationBuilder(name, filter);
|
||||||
|
@ -157,42 +152,42 @@ public class AggregationBuilders {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Sampler} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static SamplerAggregationBuilder sampler(String name) {
|
public static SamplerAggregationBuilder sampler(String name) {
|
||||||
return new SamplerAggregationBuilder(name);
|
return new SamplerAggregationBuilder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Sampler} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static DiversifiedAggregationBuilder diversifiedSampler(String name) {
|
public static DiversifiedAggregationBuilder diversifiedSampler(String name) {
|
||||||
return new DiversifiedAggregationBuilder(name);
|
return new DiversifiedAggregationBuilder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Global} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static GlobalAggregationBuilder global(String name) {
|
public static GlobalAggregationBuilder global(String name) {
|
||||||
return new GlobalAggregationBuilder(name);
|
return new GlobalAggregationBuilder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Missing} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static MissingAggregationBuilder missing(String name) {
|
public static MissingAggregationBuilder missing(String name) {
|
||||||
return new MissingAggregationBuilder(name);
|
return new MissingAggregationBuilder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link Nested} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static NestedAggregationBuilder nested(String name, String path) {
|
public static NestedAggregationBuilder nested(String name, String path) {
|
||||||
return new NestedAggregationBuilder(name, path);
|
return new NestedAggregationBuilder(name, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ReverseNested} aggregation with the given name.
|
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
|
||||||
*/
|
*/
|
||||||
public static ReverseNestedAggregationBuilder reverseNested(String name) {
|
public static ReverseNestedAggregationBuilder reverseNested(String name) {
|
||||||
return new ReverseNestedAggregationBuilder(name);
|
return new ReverseNestedAggregationBuilder(name);
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.search.aggregations;
|
|
||||||
|
|
||||||
public interface HasAggregations {
|
|
||||||
|
|
||||||
InternalAggregations getAggregations();
|
|
||||||
|
|
||||||
}
|
|
|
@ -10,7 +10,6 @@
|
||||||
package org.elasticsearch.search.aggregations.bucket;
|
package org.elasticsearch.search.aggregations.bucket;
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.HasAggregations;
|
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,7 +22,7 @@ public interface MultiBucketsAggregation extends Aggregation {
|
||||||
* A bucket represents a criteria to which all documents that fall in it adhere to. It is also uniquely identified
|
* A bucket represents a criteria to which all documents that fall in it adhere to. It is also uniquely identified
|
||||||
* by a key, and can potentially hold sub-aggregations computed over all documents in it.
|
* by a key, and can potentially hold sub-aggregations computed over all documents in it.
|
||||||
*/
|
*/
|
||||||
interface Bucket extends HasAggregations {
|
interface Bucket {
|
||||||
/**
|
/**
|
||||||
* @return The key associated with the bucket
|
* @return The key associated with the bucket
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +41,6 @@ public interface MultiBucketsAggregation extends Aggregation {
|
||||||
/**
|
/**
|
||||||
* @return The sub-aggregations of this bucket
|
* @return The sub-aggregations of this bucket
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
InternalAggregations getAggregations();
|
InternalAggregations getAggregations();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,12 @@
|
||||||
package org.elasticsearch.search.aggregations.bucket;
|
package org.elasticsearch.search.aggregations.bucket;
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.HasAggregations;
|
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single bucket aggregation
|
* A single bucket aggregation
|
||||||
*/
|
*/
|
||||||
public interface SingleBucketAggregation extends Aggregation, HasAggregations {
|
public interface SingleBucketAggregation extends Aggregation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The number of documents in this bucket
|
* @return The number of documents in this bucket
|
||||||
|
@ -26,6 +25,5 @@ public interface SingleBucketAggregation extends Aggregation, HasAggregations {
|
||||||
/**
|
/**
|
||||||
* @return The sub-aggregations of this bucket
|
* @return The sub-aggregations of this bucket
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
InternalAggregations getAggregations();
|
InternalAggregations getAggregations();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.filter;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code filter} aggregation. Defines a single bucket that holds all documents that match a specific filter.
|
|
||||||
*/
|
|
||||||
public interface Filter extends SingleBucketAggregation {}
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||||
import org.elasticsearch.search.aggregations.CardinalityUpperBound;
|
import org.elasticsearch.search.aggregations.CardinalityUpperBound;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator;
|
||||||
import org.elasticsearch.search.aggregations.support.AggregationContext;
|
import org.elasticsearch.search.aggregations.support.AggregationContext;
|
||||||
import org.elasticsearch.search.aggregations.support.AggregationPath;
|
import org.elasticsearch.search.aggregations.support.AggregationPath;
|
||||||
|
@ -50,7 +51,7 @@ public class FilterAggregationBuilder extends AbstractAggregationBuilder<FilterA
|
||||||
* @param filter
|
* @param filter
|
||||||
* Set the filter to use, only documents that match this
|
* Set the filter to use, only documents that match this
|
||||||
* filter will fall into the bucket defined by this
|
* filter will fall into the bucket defined by this
|
||||||
* {@link Filter} aggregation.
|
* {@link SingleBucketAggregation} aggregation.
|
||||||
*/
|
*/
|
||||||
public FilterAggregationBuilder(String name, QueryBuilder filter) {
|
public FilterAggregationBuilder(String name, QueryBuilder filter) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.elasticsearch.search.aggregations.support.SamplingContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalFilter extends InternalSingleBucketAggregation implements Filter {
|
public class InternalFilter extends InternalSingleBucketAggregation {
|
||||||
InternalFilter(String name, long docCount, InternalAggregations subAggregations, Map<String, Object> metadata) {
|
InternalFilter(String name, long docCount, InternalAggregations subAggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, subAggregations, metadata);
|
super(name, docCount, subAggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.global;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code global} aggregation. Defines a single bucket the holds all the documents in the search context.
|
|
||||||
*/
|
|
||||||
public interface Global extends SingleBucketAggregation {}
|
|
|
@ -11,6 +11,7 @@ package org.elasticsearch.search.aggregations.bucket.global;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -19,7 +20,7 @@ import java.util.Map;
|
||||||
* A global scope get (the document set on which we aggregate is all documents in the search context (ie. index + type)
|
* A global scope get (the document set on which we aggregate is all documents in the search context (ie. index + type)
|
||||||
* regardless the query.
|
* regardless the query.
|
||||||
*/
|
*/
|
||||||
public class InternalGlobal extends InternalSingleBucketAggregation implements Global {
|
public class InternalGlobal extends InternalSingleBucketAggregation implements SingleBucketAggregation {
|
||||||
InternalGlobal(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
InternalGlobal(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregat
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalMissing extends InternalSingleBucketAggregation implements Missing {
|
public class InternalMissing extends InternalSingleBucketAggregation {
|
||||||
InternalMissing(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
InternalMissing(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.missing;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code missing} aggregation. Defines a single bucket of all documents that are missing a specific field.
|
|
||||||
*/
|
|
||||||
public interface Missing extends SingleBucketAggregation {}
|
|
|
@ -11,6 +11,7 @@ package org.elasticsearch.search.aggregations.bucket.nested;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,7 +19,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Result of the {@link NestedAggregator}.
|
* Result of the {@link NestedAggregator}.
|
||||||
*/
|
*/
|
||||||
public class InternalNested extends InternalSingleBucketAggregation implements Nested {
|
public class InternalNested extends InternalSingleBucketAggregation implements SingleBucketAggregation {
|
||||||
InternalNested(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
InternalNested(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Result of the {@link ReverseNestedAggregator}.
|
* Result of the {@link ReverseNestedAggregator}.
|
||||||
*/
|
*/
|
||||||
public class InternalReverseNested extends InternalSingleBucketAggregation implements ReverseNested {
|
public class InternalReverseNested extends InternalSingleBucketAggregation {
|
||||||
public InternalReverseNested(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
public InternalReverseNested(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
|
||||||
super(name, docCount, aggregations, metadata);
|
super(name, docCount, aggregations, metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.nested;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code nested} aggregation. Defines a single bucket that holds all the nested documents of a specific path.
|
|
||||||
*/
|
|
||||||
public interface Nested extends SingleBucketAggregation {}
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.nested;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code reverse nested} aggregation. Defines a single bucket that holds all the parent documents for a specific nested path.
|
|
||||||
*/
|
|
||||||
public interface ReverseNested extends SingleBucketAggregation {}
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregat
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalSampler extends InternalSingleBucketAggregation implements Sampler {
|
public class InternalSampler extends InternalSingleBucketAggregation {
|
||||||
public static final String NAME = "mapped_sampler";
|
public static final String NAME = "mapped_sampler";
|
||||||
// InternalSampler and UnmappedSampler share the same parser name, so we use this when identifying the aggregation type
|
// InternalSampler and UnmappedSampler share the same parser name, so we use this when identifying the aggregation type
|
||||||
public static final String PARSER_NAME = "sampler";
|
public static final String PARSER_NAME = "sampler";
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the "Elastic License
|
|
||||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
|
||||||
* Public License v 1"; you may not use this file except in compliance with, at
|
|
||||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
|
||||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.sampler;
|
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@code filter} aggregation that defines a single bucket to hold a sample of
|
|
||||||
* top-matching documents. Computation of child aggregations is deferred until
|
|
||||||
* the top-matching documents on a shard have been determined.
|
|
||||||
*/
|
|
||||||
public interface Sampler extends SingleBucketAggregation {}
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.search.aggregations.AggregatorsReducer;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.Sampler;
|
|
||||||
import org.elasticsearch.search.aggregations.support.SamplingContext;
|
import org.elasticsearch.search.aggregations.support.SamplingContext;
|
||||||
import org.elasticsearch.xcontent.XContentBuilder;
|
import org.elasticsearch.xcontent.XContentBuilder;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalRandomSampler extends InternalSingleBucketAggregation implements Sampler {
|
public class InternalRandomSampler extends InternalSingleBucketAggregation {
|
||||||
public static final String NAME = "mapped_random_sampler";
|
public static final String NAME = "mapped_random_sampler";
|
||||||
public static final String PARSER_NAME = "random_sampler";
|
public static final String PARSER_NAME = "random_sampler";
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.InternalTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.InternalTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
||||||
|
@ -419,37 +419,37 @@ public class NestedAggregatorTests extends AggregatorTestCase {
|
||||||
|
|
||||||
Terms.Bucket bucket = terms.getBuckets().get(0);
|
Terms.Bucket bucket = terms.getBuckets().get(0);
|
||||||
assertEquals("d", bucket.getKeyAsString());
|
assertEquals("d", bucket.getKeyAsString());
|
||||||
Max numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
Max numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(3, (int) numPages.value());
|
assertEquals(3, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(1);
|
bucket = terms.getBuckets().get(1);
|
||||||
assertEquals("f", bucket.getKeyAsString());
|
assertEquals("f", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(14, (int) numPages.value());
|
assertEquals(14, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(2);
|
bucket = terms.getBuckets().get(2);
|
||||||
assertEquals("g", bucket.getKeyAsString());
|
assertEquals("g", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(18, (int) numPages.value());
|
assertEquals(18, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(3);
|
bucket = terms.getBuckets().get(3);
|
||||||
assertEquals("e", bucket.getKeyAsString());
|
assertEquals("e", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(23, (int) numPages.value());
|
assertEquals(23, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(4);
|
bucket = terms.getBuckets().get(4);
|
||||||
assertEquals("c", bucket.getKeyAsString());
|
assertEquals("c", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(39, (int) numPages.value());
|
assertEquals(39, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(5);
|
bucket = terms.getBuckets().get(5);
|
||||||
assertEquals("b", bucket.getKeyAsString());
|
assertEquals("b", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(50, (int) numPages.value());
|
assertEquals(50, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(6);
|
bucket = terms.getBuckets().get(6);
|
||||||
assertEquals("a", bucket.getKeyAsString());
|
assertEquals("a", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(70, (int) numPages.value());
|
assertEquals(70, (int) numPages.value());
|
||||||
|
|
||||||
// reverse order:
|
// reverse order:
|
||||||
|
@ -468,37 +468,37 @@ public class NestedAggregatorTests extends AggregatorTestCase {
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(0);
|
bucket = terms.getBuckets().get(0);
|
||||||
assertEquals("a", bucket.getKeyAsString());
|
assertEquals("a", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(70, (int) numPages.value());
|
assertEquals(70, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(1);
|
bucket = terms.getBuckets().get(1);
|
||||||
assertEquals("b", bucket.getKeyAsString());
|
assertEquals("b", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(50, (int) numPages.value());
|
assertEquals(50, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(2);
|
bucket = terms.getBuckets().get(2);
|
||||||
assertEquals("c", bucket.getKeyAsString());
|
assertEquals("c", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(39, (int) numPages.value());
|
assertEquals(39, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(3);
|
bucket = terms.getBuckets().get(3);
|
||||||
assertEquals("e", bucket.getKeyAsString());
|
assertEquals("e", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(23, (int) numPages.value());
|
assertEquals(23, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(4);
|
bucket = terms.getBuckets().get(4);
|
||||||
assertEquals("g", bucket.getKeyAsString());
|
assertEquals("g", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(18, (int) numPages.value());
|
assertEquals(18, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(5);
|
bucket = terms.getBuckets().get(5);
|
||||||
assertEquals("f", bucket.getKeyAsString());
|
assertEquals("f", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(14, (int) numPages.value());
|
assertEquals(14, (int) numPages.value());
|
||||||
|
|
||||||
bucket = terms.getBuckets().get(6);
|
bucket = terms.getBuckets().get(6);
|
||||||
assertEquals("d", bucket.getKeyAsString());
|
assertEquals("d", bucket.getKeyAsString());
|
||||||
numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(3, (int) numPages.value());
|
assertEquals(3, (int) numPages.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ public class NestedAggregatorTests extends AggregatorTestCase {
|
||||||
Tuple<String, int[]> book = books.get(i);
|
Tuple<String, int[]> book = books.get(i);
|
||||||
Terms.Bucket bucket = terms.getBuckets().get(i);
|
Terms.Bucket bucket = terms.getBuckets().get(i);
|
||||||
assertEquals(book.v1(), bucket.getKeyAsString());
|
assertEquals(book.v1(), bucket.getKeyAsString());
|
||||||
Min numPages = ((Nested) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
Min numPages = ((SingleBucketAggregation) bucket.getAggregations().get("chapters")).getAggregations().get("num_pages");
|
||||||
assertEquals(book.v2()[0], (int) numPages.value());
|
assertEquals(book.v2()[0], (int) numPages.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ public class NestedAggregatorTests extends AggregatorTestCase {
|
||||||
MappedFieldType fieldType1 = new KeywordFieldMapper.KeywordFieldType("key");
|
MappedFieldType fieldType1 = new KeywordFieldMapper.KeywordFieldType("key");
|
||||||
MappedFieldType fieldType2 = new KeywordFieldMapper.KeywordFieldType("value");
|
MappedFieldType fieldType2 = new KeywordFieldMapper.KeywordFieldType("value");
|
||||||
|
|
||||||
Filter filter = searchAndReduce(
|
SingleBucketAggregation filter = searchAndReduce(
|
||||||
indexReader,
|
indexReader,
|
||||||
new AggTestConfig(filterAggregationBuilder, fieldType1, fieldType2).withQuery(
|
new AggTestConfig(filterAggregationBuilder, fieldType1, fieldType2).withQuery(
|
||||||
Queries.newNonNestedFilter(IndexVersion.current())
|
Queries.newNonNestedFilter(IndexVersion.current())
|
||||||
|
@ -708,7 +708,7 @@ public class NestedAggregatorTests extends AggregatorTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
InternalNested nested = searchAndReduce(indexReader, new AggTestConfig(agg, fieldType));
|
InternalNested nested = searchAndReduce(indexReader, new AggTestConfig(agg, fieldType));
|
||||||
Nested aliasNested = searchAndReduce(indexReader, new AggTestConfig(aliasAgg, fieldType));
|
SingleBucketAggregation aliasNested = searchAndReduce(indexReader, new AggTestConfig(aliasAgg, fieldType));
|
||||||
|
|
||||||
assertEquals(nested, aliasNested);
|
assertEquals(nested, aliasNested);
|
||||||
assertEquals(expectedNestedDocs, nested.getDocCount());
|
assertEquals(expectedNestedDocs, nested.getDocCount());
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.index.mapper.Uid;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Max;
|
import org.elasticsearch.search.aggregations.metrics.Max;
|
||||||
|
@ -73,8 +74,10 @@ public class ReverseNestedAggregatorTests extends AggregatorTestCase {
|
||||||
reverseNestedBuilder.subAggregation(maxAgg);
|
reverseNestedBuilder.subAggregation(maxAgg);
|
||||||
MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(VALUE_FIELD_NAME, NumberFieldMapper.NumberType.LONG);
|
MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(VALUE_FIELD_NAME, NumberFieldMapper.NumberType.LONG);
|
||||||
|
|
||||||
Nested nested = searchAndReduce(indexReader, new AggTestConfig(nestedBuilder, fieldType));
|
SingleBucketAggregation nested = searchAndReduce(indexReader, new AggTestConfig(nestedBuilder, fieldType));
|
||||||
ReverseNested reverseNested = (ReverseNested) ((InternalAggregation) nested).getProperty(REVERSE_AGG_NAME);
|
SingleBucketAggregation reverseNested = (SingleBucketAggregation) ((InternalAggregation) nested).getProperty(
|
||||||
|
REVERSE_AGG_NAME
|
||||||
|
);
|
||||||
assertEquals(REVERSE_AGG_NAME, reverseNested.getName());
|
assertEquals(REVERSE_AGG_NAME, reverseNested.getName());
|
||||||
assertEquals(0, reverseNested.getDocCount());
|
assertEquals(0, reverseNested.getDocCount());
|
||||||
|
|
||||||
|
@ -126,10 +129,12 @@ public class ReverseNestedAggregatorTests extends AggregatorTestCase {
|
||||||
MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(VALUE_FIELD_NAME, NumberFieldMapper.NumberType.LONG);
|
MappedFieldType fieldType = new NumberFieldMapper.NumberFieldType(VALUE_FIELD_NAME, NumberFieldMapper.NumberType.LONG);
|
||||||
|
|
||||||
AggTestConfig aggTestConfig = new AggTestConfig(nestedBuilder, fieldType);
|
AggTestConfig aggTestConfig = new AggTestConfig(nestedBuilder, fieldType);
|
||||||
Nested nested = searchAndReduce(indexReader, aggTestConfig);
|
SingleBucketAggregation nested = searchAndReduce(indexReader, aggTestConfig);
|
||||||
assertEquals(expectedNestedDocs, nested.getDocCount());
|
assertEquals(expectedNestedDocs, nested.getDocCount());
|
||||||
|
|
||||||
ReverseNested reverseNested = (ReverseNested) ((InternalAggregation) nested).getProperty(REVERSE_AGG_NAME);
|
SingleBucketAggregation reverseNested = (SingleBucketAggregation) ((InternalAggregation) nested).getProperty(
|
||||||
|
REVERSE_AGG_NAME
|
||||||
|
);
|
||||||
assertEquals(REVERSE_AGG_NAME, reverseNested.getName());
|
assertEquals(REVERSE_AGG_NAME, reverseNested.getName());
|
||||||
assertEquals(expectedParentDocs, reverseNested.getDocCount());
|
assertEquals(expectedParentDocs, reverseNested.getDocCount());
|
||||||
|
|
||||||
|
@ -185,11 +190,11 @@ public class ReverseNestedAggregatorTests extends AggregatorTestCase {
|
||||||
reverseNested(REVERSE_AGG_NAME).subAggregation(aliasMaxAgg)
|
reverseNested(REVERSE_AGG_NAME).subAggregation(aliasMaxAgg)
|
||||||
);
|
);
|
||||||
|
|
||||||
Nested nested = searchAndReduce(indexReader, new AggTestConfig(agg, fieldType));
|
SingleBucketAggregation nested = searchAndReduce(indexReader, new AggTestConfig(agg, fieldType));
|
||||||
Nested aliasNested = searchAndReduce(indexReader, new AggTestConfig(aliasAgg, fieldType));
|
SingleBucketAggregation aliasNested = searchAndReduce(indexReader, new AggTestConfig(aliasAgg, fieldType));
|
||||||
|
|
||||||
ReverseNested reverseNested = nested.getAggregations().get(REVERSE_AGG_NAME);
|
SingleBucketAggregation reverseNested = nested.getAggregations().get(REVERSE_AGG_NAME);
|
||||||
ReverseNested aliasReverseNested = aliasNested.getAggregations().get(REVERSE_AGG_NAME);
|
SingleBucketAggregation aliasReverseNested = aliasNested.getAggregations().get(REVERSE_AGG_NAME);
|
||||||
|
|
||||||
assertEquals(reverseNested, aliasReverseNested);
|
assertEquals(reverseNested, aliasReverseNested);
|
||||||
assertEquals(expectedParentDocs, reverseNested.getDocCount());
|
assertEquals(expectedParentDocs, reverseNested.getDocCount());
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Avg;
|
import org.elasticsearch.search.aggregations.metrics.Avg;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Max;
|
import org.elasticsearch.search.aggregations.metrics.Max;
|
||||||
import org.elasticsearch.search.aggregations.metrics.Min;
|
import org.elasticsearch.search.aggregations.metrics.Min;
|
||||||
|
@ -121,9 +121,9 @@ public class RandomSamplerAggregatorTests extends AggregatorTestCase {
|
||||||
// sampled doc count is NOT scaled, and thus should be lower
|
// sampled doc count is NOT scaled, and thus should be lower
|
||||||
testCase(RandomSamplerAggregatorTests::writeTestDocs, (InternalRandomSampler result) -> {
|
testCase(RandomSamplerAggregatorTests::writeTestDocs, (InternalRandomSampler result) -> {
|
||||||
long sampledDocCount = result.getDocCount();
|
long sampledDocCount = result.getDocCount();
|
||||||
Filter agg = result.getAggregations().get("filter_outer");
|
SingleBucketAggregation agg = result.getAggregations().get("filter_outer");
|
||||||
long outerFilterDocCount = agg.getDocCount();
|
long outerFilterDocCount = agg.getDocCount();
|
||||||
Filter innerAgg = agg.getAggregations().get("filter_inner");
|
SingleBucketAggregation innerAgg = agg.getAggregations().get("filter_inner");
|
||||||
long innerFilterDocCount = innerAgg.getDocCount();
|
long innerFilterDocCount = innerAgg.getDocCount();
|
||||||
if (sampledDocCount == 0) {
|
if (sampledDocCount == 0) {
|
||||||
// in case 0 docs get sampled, which can rarely happen
|
// in case 0 docs get sampled, which can rarely happen
|
||||||
|
|
|
@ -88,7 +88,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
|
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.MultiBucketConsumerService.TooManyBucketsException;
|
import org.elasticsearch.search.aggregations.MultiBucketConsumerService.TooManyBucketsException;
|
||||||
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
|
||||||
|
@ -1109,7 +1109,7 @@ public class TermsAggregatorTests extends AggregatorTestCase {
|
||||||
.collectMode(randomFrom(Aggregator.SubAggCollectionMode.values()))
|
.collectMode(randomFrom(Aggregator.SubAggCollectionMode.values()))
|
||||||
.field("field")
|
.field("field")
|
||||||
);
|
);
|
||||||
result = ((Filter) searchAndReduce(
|
result = ((SingleBucketAggregation) searchAndReduce(
|
||||||
indexReader,
|
indexReader,
|
||||||
new AggTestConfig(aggregationBuilder, fieldType, filterFieldType).withSplitLeavesIntoSeperateAggregators(false)
|
new AggTestConfig(aggregationBuilder, fieldType, filterFieldType).withSplitLeavesIntoSeperateAggregators(false)
|
||||||
)).getAggregations().get("_name2");
|
)).getAggregations().get("_name2");
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||||
|
@ -513,7 +513,7 @@ public class AvgAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals((long) i + 1, bucket.getKeyAsNumber());
|
assertEquals((long) i + 1, bucket.getKeyAsNumber());
|
||||||
assertEquals(1L, bucket.getDocCount());
|
assertEquals(1L, bucket.getDocCount());
|
||||||
|
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertNotNull(filter);
|
assertNotNull(filter);
|
||||||
assertEquals(0L, filter.getDocCount());
|
assertEquals(0L, filter.getDocCount());
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||||
|
@ -764,7 +764,7 @@ public class CardinalityAggregatorTests extends AggregatorTestCase {
|
||||||
iw.addDocument(singleton(new NumericDocValuesField("number", (i + 1))));
|
iw.addDocument(singleton(new NumericDocValuesField("number", (i + 1))));
|
||||||
}
|
}
|
||||||
}, topLevelAgg -> {
|
}, topLevelAgg -> {
|
||||||
final Global global = (Global) topLevelAgg;
|
final SingleBucketAggregation global = (SingleBucketAggregation) topLevelAgg;
|
||||||
assertNotNull(global);
|
assertNotNull(global);
|
||||||
assertEquals("global", global.getName());
|
assertEquals("global", global.getName());
|
||||||
assertEquals(numDocs * 2, global.getDocCount());
|
assertEquals(numDocs * 2, global.getDocCount());
|
||||||
|
|
|
@ -51,8 +51,7 @@ import org.elasticsearch.search.aggregations.BucketCollector;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.MultiBucketCollector;
|
import org.elasticsearch.search.aggregations.MultiBucketCollector;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
|
||||||
|
@ -436,7 +435,7 @@ public class MaxAggregatorTests extends AggregatorTestCase {
|
||||||
|
|
||||||
DirectoryReader indexReader = DirectoryReader.open(directory);
|
DirectoryReader indexReader = DirectoryReader.open(directory);
|
||||||
|
|
||||||
Global global = searchAndReduce(indexReader, new AggTestConfig(aggregationBuilder, fieldType));
|
SingleBucketAggregation global = searchAndReduce(indexReader, new AggTestConfig(aggregationBuilder, fieldType));
|
||||||
assertNotNull(global);
|
assertNotNull(global);
|
||||||
assertEquals("global", global.getName());
|
assertEquals("global", global.getName());
|
||||||
assertEquals(10L, global.getDocCount());
|
assertEquals(10L, global.getDocCount());
|
||||||
|
@ -647,7 +646,7 @@ public class MaxAggregatorTests extends AggregatorTestCase {
|
||||||
|
|
||||||
DirectoryReader indexReader = DirectoryReader.open(directory);
|
DirectoryReader indexReader = DirectoryReader.open(directory);
|
||||||
|
|
||||||
Global global = searchAndReduce(indexReader, new AggTestConfig(aggregationBuilder, fieldType));
|
SingleBucketAggregation global = searchAndReduce(indexReader, new AggTestConfig(aggregationBuilder, fieldType));
|
||||||
assertNotNull(global);
|
assertNotNull(global);
|
||||||
assertEquals("global", global.getName());
|
assertEquals("global", global.getName());
|
||||||
assertEquals(0L, global.getDocCount());
|
assertEquals(0L, global.getDocCount());
|
||||||
|
@ -695,7 +694,7 @@ public class MaxAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals((long) i + 1, bucket.getKeyAsNumber());
|
assertEquals((long) i + 1, bucket.getKeyAsNumber());
|
||||||
assertEquals(1L, bucket.getDocCount());
|
assertEquals(1L, bucket.getDocCount());
|
||||||
|
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertNotNull(filter);
|
assertNotNull(filter);
|
||||||
assertEquals(0L, filter.getDocCount());
|
assertEquals(0L, filter.getDocCount());
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
||||||
|
@ -530,7 +530,7 @@ public class MinAggregatorTests extends AggregatorTestCase {
|
||||||
assertEquals((long) i1 + 1, bucket.getKeyAsNumber());
|
assertEquals((long) i1 + 1, bucket.getKeyAsNumber());
|
||||||
assertEquals(1L, bucket.getDocCount());
|
assertEquals(1L, bucket.getDocCount());
|
||||||
|
|
||||||
Filter filter = bucket.getAggregations().get("filter");
|
SingleBucketAggregation filter = bucket.getAggregations().get("filter");
|
||||||
assertNotNull(filter);
|
assertNotNull(filter);
|
||||||
assertEquals(0L, filter.getDocCount());
|
assertEquals(0L, filter.getDocCount());
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.elasticsearch.search.aggregations.metrics;
|
||||||
import org.elasticsearch.common.geo.GeoPoint;
|
import org.elasticsearch.common.geo.GeoPoint;
|
||||||
import org.elasticsearch.common.geo.SpatialPoint;
|
import org.elasticsearch.common.geo.SpatialPoint;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public abstract class CentroidAggregationTestBase extends AbstractGeoTestCase {
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.addAggregation(global("global").subAggregation(centroidAgg(aggName()).field(SINGLE_VALUED_FIELD_NAME))),
|
.addAggregation(global("global").subAggregation(centroidAgg(aggName()).field(SINGLE_VALUED_FIELD_NAME))),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.elasticsearch.search.aggregations.metrics;
|
||||||
import org.elasticsearch.common.geo.SpatialPoint;
|
import org.elasticsearch.common.geo.SpatialPoint;
|
||||||
import org.elasticsearch.common.util.BigArray;
|
import org.elasticsearch.common.util.BigArray;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||||
|
@ -63,7 +63,7 @@ public abstract class SpatialBoundsAggregationTestBase<T extends SpatialPoint> e
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.addAggregation(global("global").subAggregation(boundsAgg(aggName(), SINGLE_VALUED_FIELD_NAME))),
|
.addAggregation(global("global").subAggregation(boundsAgg(aggName(), SINGLE_VALUED_FIELD_NAME))),
|
||||||
response -> {
|
response -> {
|
||||||
Global global = response.getAggregations().get("global");
|
SingleBucketAggregation global = response.getAggregations().get("global");
|
||||||
assertThat(global, notNullValue());
|
assertThat(global, notNullValue());
|
||||||
assertThat(global.getName(), equalTo("global"));
|
assertThat(global.getName(), equalTo("global"));
|
||||||
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
assertThat(global.getDocCount(), equalTo((long) numDocs));
|
||||||
|
|
|
@ -17,8 +17,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.Nested;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.Percentiles;
|
import org.elasticsearch.search.aggregations.metrics.Percentiles;
|
||||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
|
@ -179,13 +178,13 @@ public class AucRoc extends AbstractAucRoc {
|
||||||
if (result.get() != null) {
|
if (result.get() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Filter classAgg = aggs.get(TRUE_AGG_NAME);
|
SingleBucketAggregation classAgg = aggs.get(TRUE_AGG_NAME);
|
||||||
Nested classNested = classAgg.getAggregations().get(NESTED_AGG_NAME);
|
SingleBucketAggregation classNested = classAgg.getAggregations().get(NESTED_AGG_NAME);
|
||||||
Filter classNestedFilter = classNested.getAggregations().get(NESTED_FILTER_AGG_NAME);
|
SingleBucketAggregation classNestedFilter = classNested.getAggregations().get(NESTED_FILTER_AGG_NAME);
|
||||||
|
|
||||||
Filter restAgg = aggs.get(NON_TRUE_AGG_NAME);
|
SingleBucketAggregation restAgg = aggs.get(NON_TRUE_AGG_NAME);
|
||||||
Nested restNested = restAgg.getAggregations().get(NESTED_AGG_NAME);
|
SingleBucketAggregation restNested = restAgg.getAggregations().get(NESTED_AGG_NAME);
|
||||||
Filter restNestedFilter = restNested.getAggregations().get(NESTED_FILTER_AGG_NAME);
|
SingleBucketAggregation restNestedFilter = restNested.getAggregations().get(NESTED_FILTER_AGG_NAME);
|
||||||
|
|
||||||
if (classAgg.getDocCount() == 0) {
|
if (classAgg.getDocCount() == 0) {
|
||||||
throw ExceptionsHelper.badRequestException(
|
throw ExceptionsHelper.badRequestException(
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.XContentBuilder;
|
import org.elasticsearch.xcontent.XContentBuilder;
|
||||||
|
@ -159,7 +159,7 @@ public class AucRoc extends AbstractAucRoc {
|
||||||
if (result.get() != null) {
|
if (result.get() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Filter classAgg = aggs.get(TRUE_AGG_NAME);
|
SingleBucketAggregation classAgg = aggs.get(TRUE_AGG_NAME);
|
||||||
if (classAgg.getDocCount() == 0) {
|
if (classAgg.getDocCount() == 0) {
|
||||||
throw ExceptionsHelper.badRequestException(
|
throw ExceptionsHelper.badRequestException(
|
||||||
"[{}] requires at least one [{}] to have the value [{}]",
|
"[{}] requires at least one [{}] to have the value [{}]",
|
||||||
|
@ -169,7 +169,7 @@ public class AucRoc extends AbstractAucRoc {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
double[] tpPercentiles = percentilesArray(classAgg.getAggregations().get(PERCENTILES_AGG_NAME));
|
double[] tpPercentiles = percentilesArray(classAgg.getAggregations().get(PERCENTILES_AGG_NAME));
|
||||||
Filter restAgg = aggs.get(NON_TRUE_AGG_NAME);
|
SingleBucketAggregation restAgg = aggs.get(NON_TRUE_AGG_NAME);
|
||||||
if (restAgg.getDocCount() == 0) {
|
if (restAgg.getDocCount() == 0) {
|
||||||
throw ExceptionsHelper.badRequestException(
|
throw ExceptionsHelper.badRequestException(
|
||||||
"[{}] requires at least one [{}] to have a different value than [{}]",
|
"[{}] requires at least one [{}] to have a different value than [{}]",
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.XContentBuilder;
|
import org.elasticsearch.xcontent.XContentBuilder;
|
||||||
|
@ -93,10 +93,10 @@ public class ConfusionMatrix extends AbstractConfusionMatrixMetric {
|
||||||
long[] tn = new long[thresholds.length];
|
long[] tn = new long[thresholds.length];
|
||||||
long[] fn = new long[thresholds.length];
|
long[] fn = new long[thresholds.length];
|
||||||
for (int i = 0; i < thresholds.length; i++) {
|
for (int i = 0; i < thresholds.length; i++) {
|
||||||
Filter tpAgg = aggs.get(aggName(thresholds[i], Condition.TP));
|
SingleBucketAggregation tpAgg = aggs.get(aggName(thresholds[i], Condition.TP));
|
||||||
Filter fpAgg = aggs.get(aggName(thresholds[i], Condition.FP));
|
SingleBucketAggregation fpAgg = aggs.get(aggName(thresholds[i], Condition.FP));
|
||||||
Filter tnAgg = aggs.get(aggName(thresholds[i], Condition.TN));
|
SingleBucketAggregation tnAgg = aggs.get(aggName(thresholds[i], Condition.TN));
|
||||||
Filter fnAgg = aggs.get(aggName(thresholds[i], Condition.FN));
|
SingleBucketAggregation fnAgg = aggs.get(aggName(thresholds[i], Condition.FN));
|
||||||
tp[i] = tpAgg.getDocCount();
|
tp[i] = tpAgg.getDocCount();
|
||||||
fp[i] = fpAgg.getDocCount();
|
fp[i] = fpAgg.getDocCount();
|
||||||
tn[i] = tnAgg.getDocCount();
|
tn[i] = tnAgg.getDocCount();
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.elasticsearch.xpack.core.ml.dataframe.evaluation.outlierdetection;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.XContentParser;
|
import org.elasticsearch.xcontent.XContentParser;
|
||||||
|
@ -87,8 +87,8 @@ public class Precision extends AbstractConfusionMatrixMetric {
|
||||||
double[] precisions = new double[thresholds.length];
|
double[] precisions = new double[thresholds.length];
|
||||||
for (int i = 0; i < thresholds.length; i++) {
|
for (int i = 0; i < thresholds.length; i++) {
|
||||||
double threshold = thresholds[i];
|
double threshold = thresholds[i];
|
||||||
Filter tpAgg = aggs.get(aggName(threshold, Condition.TP));
|
SingleBucketAggregation tpAgg = aggs.get(aggName(threshold, Condition.TP));
|
||||||
Filter fpAgg = aggs.get(aggName(threshold, Condition.FP));
|
SingleBucketAggregation fpAgg = aggs.get(aggName(threshold, Condition.FP));
|
||||||
long tp = tpAgg.getDocCount();
|
long tp = tpAgg.getDocCount();
|
||||||
long fp = fpAgg.getDocCount();
|
long fp = fpAgg.getDocCount();
|
||||||
precisions[i] = tp + fp == 0 ? 0.0 : (double) tp / (tp + fp);
|
precisions[i] = tp + fp == 0 ? 0.0 : (double) tp / (tp + fp);
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.elasticsearch.xpack.core.ml.dataframe.evaluation.outlierdetection;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.xcontent.ParseField;
|
import org.elasticsearch.xcontent.ParseField;
|
||||||
import org.elasticsearch.xcontent.XContentParser;
|
import org.elasticsearch.xcontent.XContentParser;
|
||||||
|
@ -87,8 +87,8 @@ public class Recall extends AbstractConfusionMatrixMetric {
|
||||||
double[] recalls = new double[thresholds.length];
|
double[] recalls = new double[thresholds.length];
|
||||||
for (int i = 0; i < thresholds.length; i++) {
|
for (int i = 0; i < thresholds.length; i++) {
|
||||||
double threshold = thresholds[i];
|
double threshold = thresholds[i];
|
||||||
Filter tpAgg = aggs.get(aggName(threshold, Condition.TP));
|
SingleBucketAggregation tpAgg = aggs.get(aggName(threshold, Condition.TP));
|
||||||
Filter fnAgg = aggs.get(aggName(threshold, Condition.FN));
|
SingleBucketAggregation fnAgg = aggs.get(aggName(threshold, Condition.FN));
|
||||||
long tp = tpAgg.getDocCount();
|
long tp = tpAgg.getDocCount();
|
||||||
long fn = fnAgg.getDocCount();
|
long fn = fnAgg.getDocCount();
|
||||||
recalls[i] = tp + fn == 0 ? 0.0 : (double) tp / (tp + fn);
|
recalls[i] = tp + fn == 0 ? 0.0 : (double) tp / (tp + fn);
|
||||||
|
|
|
@ -40,8 +40,8 @@ import org.elasticsearch.protocol.xpack.graph.Vertex.VertexId;
|
||||||
import org.elasticsearch.protocol.xpack.graph.VertexRequest;
|
import org.elasticsearch.protocol.xpack.graph.VertexRequest;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.sampler.DiversifiedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.Sampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms.Bucket;
|
import org.elasticsearch.search.aggregations.bucket.terms.SignificantTerms.Bucket;
|
||||||
|
@ -337,7 +337,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
||||||
|
|
||||||
ArrayList<Connection> newConnections = new ArrayList<Connection>();
|
ArrayList<Connection> newConnections = new ArrayList<Connection>();
|
||||||
ArrayList<Vertex> newVertices = new ArrayList<Vertex>();
|
ArrayList<Vertex> newVertices = new ArrayList<Vertex>();
|
||||||
Sampler sample = searchResponse.getAggregations().get("sample");
|
SingleBucketAggregation sample = searchResponse.getAggregations().get("sample");
|
||||||
|
|
||||||
// We think of the total scores as the energy-level pouring
|
// We think of the total scores as the energy-level pouring
|
||||||
// out of all the last hop's connections.
|
// out of all the last hop's connections.
|
||||||
|
@ -365,7 +365,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
||||||
private void addAndScoreNewVertices(
|
private void addAndScoreNewVertices(
|
||||||
Hop lastHop,
|
Hop lastHop,
|
||||||
Hop currentHop,
|
Hop currentHop,
|
||||||
Sampler sample,
|
SingleBucketAggregation sample,
|
||||||
double totalSignalOutput,
|
double totalSignalOutput,
|
||||||
ArrayList<Connection> newConnections,
|
ArrayList<Connection> newConnections,
|
||||||
ArrayList<Vertex> newVertices
|
ArrayList<Vertex> newVertices
|
||||||
|
@ -500,7 +500,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
||||||
// we can do something server-side here
|
// we can do something server-side here
|
||||||
|
|
||||||
// Helper method - compute the total signal of all scores in the search results
|
// Helper method - compute the total signal of all scores in the search results
|
||||||
private double getExpandTotalSignalStrength(Hop lastHop, Hop currentHop, Sampler sample) {
|
private double getExpandTotalSignalStrength(Hop lastHop, Hop currentHop, SingleBucketAggregation sample) {
|
||||||
double totalSignalOutput = 0;
|
double totalSignalOutput = 0;
|
||||||
for (int j = 0; j < lastHop.getNumberVertexRequests(); j++) {
|
for (int j = 0; j < lastHop.getNumberVertexRequests(); j++) {
|
||||||
VertexRequest lastVr = lastHop.getVertexRequest(j);
|
VertexRequest lastVr = lastHop.getVertexRequest(j);
|
||||||
|
@ -686,7 +686,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SearchResponse searchResponse) {
|
public void onResponse(SearchResponse searchResponse) {
|
||||||
addShardFailures(searchResponse.getShardFailures());
|
addShardFailures(searchResponse.getShardFailures());
|
||||||
Sampler sample = searchResponse.getAggregations().get("sample");
|
SingleBucketAggregation sample = searchResponse.getAggregations().get("sample");
|
||||||
|
|
||||||
// Determine the total scores for all interesting terms
|
// Determine the total scores for all interesting terms
|
||||||
double totalSignalStrength = getInitialTotalSignalStrength(rootHop, sample);
|
double totalSignalStrength = getInitialTotalSignalStrength(rootHop, sample);
|
||||||
|
@ -724,7 +724,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method - Provides a total signal strength for all terms connected to the initial query
|
// Helper method - Provides a total signal strength for all terms connected to the initial query
|
||||||
private double getInitialTotalSignalStrength(Hop rootHop, Sampler sample) {
|
private double getInitialTotalSignalStrength(Hop rootHop, SingleBucketAggregation sample) {
|
||||||
double totalSignalStrength = 0;
|
double totalSignalStrength = 0;
|
||||||
for (int i = 0; i < rootHop.getNumberVertexRequests(); i++) {
|
for (int i = 0; i < rootHop.getNumberVertexRequests(); i++) {
|
||||||
if (request.useSignificance()) {
|
if (request.useSignificance()) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
import org.elasticsearch.search.aggregations.bucket.terms.IncludeExclude;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
||||||
|
@ -960,7 +960,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
||||||
assertHitCount(response, 3);
|
assertHitCount(response, 3);
|
||||||
assertSearchHits(response, "1", "2", "3");
|
assertSearchHits(response, "1", "2", "3");
|
||||||
|
|
||||||
Global globalAgg = response.getAggregations().get("global");
|
SingleBucketAggregation globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(3L));
|
assertThat(globalAgg.getDocCount(), equalTo(3L));
|
||||||
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value2"));
|
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value2"));
|
||||||
|
@ -975,7 +975,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertSearchHits(response, "1");
|
assertSearchHits(response, "1");
|
||||||
|
|
||||||
Global globalAgg = response.getAggregations().get("global");
|
SingleBucketAggregation globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(1L));
|
assertThat(globalAgg.getDocCount(), equalTo(1L));
|
||||||
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
assertThat(termsAgg.getBuckets().size(), equalTo(0));
|
||||||
|
@ -989,7 +989,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
assertSearchHits(response, "2");
|
assertSearchHits(response, "2");
|
||||||
|
|
||||||
Global globalAgg = response.getAggregations().get("global");
|
SingleBucketAggregation globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(1L));
|
assertThat(globalAgg.getDocCount(), equalTo(1L));
|
||||||
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().size(), equalTo(1));
|
assertThat(termsAgg.getBuckets().size(), equalTo(1));
|
||||||
|
@ -1003,7 +1003,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
||||||
assertHitCount(response, 2);
|
assertHitCount(response, 2);
|
||||||
assertSearchHits(response, "1", "2");
|
assertSearchHits(response, "1", "2");
|
||||||
|
|
||||||
Global globalAgg = response.getAggregations().get("global");
|
SingleBucketAggregation globalAgg = response.getAggregations().get("global");
|
||||||
assertThat(globalAgg.getDocCount(), equalTo(2L));
|
assertThat(globalAgg.getDocCount(), equalTo(2L));
|
||||||
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
Terms termsAgg = globalAgg.getAggregations().get("field2");
|
||||||
assertThat(termsAgg.getBuckets().size(), equalTo(1));
|
assertThat(termsAgg.getBuckets().size(), equalTo(1));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue