|
@@ -24,6 +24,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
|
|
import org.elasticsearch.action.search.SearchResponse;
|
|
import org.elasticsearch.action.search.SearchResponse;
|
|
import org.elasticsearch.index.mapper.internal.IndexFieldMapper;
|
|
import org.elasticsearch.index.mapper.internal.IndexFieldMapper;
|
|
import org.elasticsearch.index.query.FilterBuilders;
|
|
import org.elasticsearch.index.query.FilterBuilders;
|
|
|
|
+import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
|
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
|
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.terms.Terms;
|
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
|
@@ -109,6 +110,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.minDocCount(minDocCount)
|
|
.minDocCount(minDocCount)
|
|
.size(0))
|
|
.size(0))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
@@ -126,7 +128,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -157,7 +160,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(executionMode == null ? null : executionMode.toString())
|
|
.executionHint(executionMode == null ? null : executionMode.toString())
|
|
- .field(SINGLE_VALUED_FIELD_NAME))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
|
|
|
|
@@ -183,7 +187,9 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).include("val00.+"))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
|
|
+ .include("val00.+"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -206,7 +212,9 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).include("val00.+").exclude("(val000|val001)"))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
|
|
+ .include("val00.+").exclude("(val000|val001)"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -229,7 +237,9 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).exclude("val0[1-9]+.+"))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
|
|
+ .exclude("val0[1-9]+.+"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -257,7 +267,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).include("VAL00.+", Pattern.CASE_INSENSITIVE))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())).include("VAL00.+", Pattern.CASE_INSENSITIVE))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -281,7 +292,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).include("val00.+").exclude("( val000 | VAL001 )#this is a comment", Pattern.CASE_INSENSITIVE | Pattern.COMMENTS))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())).include("val00.+").exclude("( val000 | VAL001 )#this is a comment", Pattern.CASE_INSENSITIVE | Pattern.COMMENTS))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -305,7 +317,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
response = client().prepareSearch("idx").setTypes("high_card_type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME).exclude("val0[1-9]+.+", 0))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())).exclude("val0[1-9]+.+", 0))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -331,6 +344,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.size(20)
|
|
.size(20)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.term(true))) // we need to sort by terms cause we're checking the first 20 values
|
|
.order(Terms.Order.term(true))) // we need to sort by terms cause we're checking the first 20 values
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -355,6 +369,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.term(true)))
|
|
.order(Terms.Order.term(true)))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -380,6 +395,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.term(false)))
|
|
.order(Terms.Order.term(false)))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -405,6 +421,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.subAggregation(count("count").field(MULTI_VALUED_FIELD_NAME)))
|
|
.subAggregation(count("count").field(MULTI_VALUED_FIELD_NAME)))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -432,6 +449,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.subAggregation(count("count")))
|
|
.subAggregation(count("count")))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -459,6 +477,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.script("'foo_' + _value"))
|
|
.script("'foo_' + _value"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -483,6 +502,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.script("_value.substring(0,3)"))
|
|
.script("_value.substring(0,3)"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -504,7 +524,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(MULTI_VALUED_FIELD_NAME))
|
|
|
|
|
|
+ .field(MULTI_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -532,6 +553,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.script("'foo_' + _value"))
|
|
.script("'foo_' + _value"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
@@ -578,6 +600,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
.field(MULTI_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.script("'foo_' + _value")
|
|
.script("'foo_' + _value")
|
|
.subAggregation(count("count")))
|
|
.subAggregation(count("count")))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
@@ -611,6 +634,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void script_SingleValue() throws Exception {
|
|
public void script_SingleValue() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value"))
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
@@ -634,6 +658,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void script_SingleValue_ExplicitSingleValue() throws Exception {
|
|
public void script_SingleValue_ExplicitSingleValue() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value"))
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
@@ -657,6 +682,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
|
|
public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value")
|
|
.script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value")
|
|
.subAggregation(count("count")))
|
|
.subAggregation(count("count")))
|
|
@@ -684,6 +710,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void script_MultiValued() throws Exception {
|
|
public void script_MultiValued() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.script("doc['" + MULTI_VALUED_FIELD_NAME + "'].values"))
|
|
.script("doc['" + MULTI_VALUED_FIELD_NAME + "'].values"))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
@@ -711,6 +738,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void script_MultiValued_WithAggregatorInherited() throws Exception {
|
|
public void script_MultiValued_WithAggregatorInherited() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.script("doc['" + MULTI_VALUED_FIELD_NAME + "'].values")
|
|
.script("doc['" + MULTI_VALUED_FIELD_NAME + "'].values")
|
|
.subAggregation(count("count")))
|
|
.subAggregation(count("count")))
|
|
@@ -747,7 +775,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.size(randomInt(5))
|
|
.size(randomInt(5))
|
|
- .field(SINGLE_VALUED_FIELD_NAME))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -763,7 +792,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
SearchResponse response = client().prepareSearch("idx", "idx_unmapped").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx", "idx_unmapped").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
- .field(SINGLE_VALUED_FIELD_NAME))
|
|
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertSearchResponse(response);
|
|
assertSearchResponse(response);
|
|
@@ -785,7 +815,8 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
public void stringTermsNestedIntoPerBucketAggregator() throws Exception {
|
|
public void stringTermsNestedIntoPerBucketAggregator() throws Exception {
|
|
// no execution hint so that the logic that decides whether or not to use ordinals is executed
|
|
// no execution hint so that the logic that decides whether or not to use ordinals is executed
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
- .addAggregation(filter("filter").filter(termFilter(MULTI_VALUED_FIELD_NAME, "val3")).subAggregation(terms("terms").field(MULTI_VALUED_FIELD_NAME)))
|
|
|
|
|
|
+ .addAggregation(filter("filter").filter(termFilter(MULTI_VALUED_FIELD_NAME, "val3")).subAggregation(terms("terms").field(MULTI_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))))
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
|
|
|
assertThat(response.getFailedShards(), equalTo(0));
|
|
assertThat(response.getFailedShards(), equalTo(0));
|
|
@@ -832,6 +863,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("avg_i", asc))
|
|
.order(Terms.Order.aggregation("avg_i", asc))
|
|
.subAggregation(avg("avg_i").field("i"))
|
|
.subAggregation(avg("avg_i").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -863,6 +895,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("tags")
|
|
.addAggregation(terms("tags")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field("tag")
|
|
.field("tag")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("filter", asc))
|
|
.order(Terms.Order.aggregation("filter", asc))
|
|
.subAggregation(filter("filter").filter(FilterBuilders.matchAllFilter()))
|
|
.subAggregation(filter("filter").filter(FilterBuilders.matchAllFilter()))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -901,6 +934,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("tags")
|
|
.addAggregation(terms("tags")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field("tag")
|
|
.field("tag")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("filter1>filter2>stats.max", asc))
|
|
.order(Terms.Order.aggregation("filter1>filter2>stats.max", asc))
|
|
.subAggregation(filter("filter1").filter(FilterBuilders.matchAllFilter())
|
|
.subAggregation(filter("filter1").filter(FilterBuilders.matchAllFilter())
|
|
.subAggregation(filter("filter2").filter(FilterBuilders.matchAllFilter())
|
|
.subAggregation(filter("filter2").filter(FilterBuilders.matchAllFilter())
|
|
@@ -958,6 +992,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("avg_i", true))
|
|
.order(Terms.Order.aggregation("avg_i", true))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
|
|
|
|
@@ -976,8 +1011,10 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("values", true))
|
|
.order(Terms.Order.aggregation("values", true))
|
|
- .subAggregation(terms("values").field("i"))
|
|
|
|
|
|
+ .subAggregation(terms("values").field("i")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
|
|
|
|
fail("Expected search to fail when trying to sort terms aggregation by sug-aggregation which is not of a metrics or single-bucket type");
|
|
fail("Expected search to fail when trying to sort terms aggregation by sug-aggregation which is not of a metrics or single-bucket type");
|
|
@@ -994,6 +1031,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("stats.foo", true))
|
|
.order(Terms.Order.aggregation("stats.foo", true))
|
|
.subAggregation(stats("stats").field("i"))
|
|
.subAggregation(stats("stats").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1014,6 +1052,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("stats", true))
|
|
.order(Terms.Order.aggregation("stats", true))
|
|
.subAggregation(stats("stats").field("i"))
|
|
.subAggregation(stats("stats").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1033,6 +1072,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("avg_i", asc))
|
|
.order(Terms.Order.aggregation("avg_i", asc))
|
|
.subAggregation(avg("avg_i").field("i"))
|
|
.subAggregation(avg("avg_i").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1066,6 +1106,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("stats.avg", asc))
|
|
.order(Terms.Order.aggregation("stats.avg", asc))
|
|
.subAggregation(stats("stats").field("i"))
|
|
.subAggregation(stats("stats").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1098,6 +1139,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("stats.avg", asc))
|
|
.order(Terms.Order.aggregation("stats.avg", asc))
|
|
.subAggregation(stats("stats").field("i"))
|
|
.subAggregation(stats("stats").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1130,6 +1172,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
.field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.order(Terms.Order.aggregation("stats.sum_of_squares", asc))
|
|
.order(Terms.Order.aggregation("stats.sum_of_squares", asc))
|
|
.subAggregation(extendedStats("stats").field("i"))
|
|
.subAggregation(extendedStats("stats").field("i"))
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|
|
@@ -1154,11 +1197,57 @@ public class StringTermsTests extends ElasticsearchIntegrationTest {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void singleValuedField_OrderedByStatsAggAscWithTermsSubAgg() throws Exception {
|
|
|
|
+ boolean asc = true;
|
|
|
|
+ SearchResponse response = client().prepareSearch("idx").setTypes("type")
|
|
|
|
+ .addAggregation(terms("terms")
|
|
|
|
+ .executionHint(randomExecutionHint())
|
|
|
|
+ .field(SINGLE_VALUED_FIELD_NAME)
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
|
|
+ .order(Terms.Order.aggregation("stats.sum_of_squares", asc))
|
|
|
|
+ .subAggregation(extendedStats("stats").field("i")).subAggregation(terms("subTerms").field("s_values")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values())))
|
|
|
|
+ ).execute().actionGet();
|
|
|
|
+
|
|
|
|
+ assertSearchResponse(response);
|
|
|
|
+
|
|
|
|
+ Terms terms = response.getAggregations().get("terms");
|
|
|
|
+ assertThat(terms, notNullValue());
|
|
|
|
+ assertThat(terms.getName(), equalTo("terms"));
|
|
|
|
+ assertThat(terms.getBuckets().size(), equalTo(5));
|
|
|
|
+
|
|
|
|
+ int i = 0;
|
|
|
|
+ for (Terms.Bucket bucket : terms.getBuckets()) {
|
|
|
|
+ assertThat(bucket, notNullValue());
|
|
|
|
+ assertThat(key(bucket), equalTo("val" + i));
|
|
|
|
+ assertThat(bucket.getDocCount(), equalTo(1l));
|
|
|
|
+
|
|
|
|
+ ExtendedStats stats = bucket.getAggregations().get("stats");
|
|
|
|
+ assertThat(stats, notNullValue());
|
|
|
|
+ assertThat(stats.getMax(), equalTo((double) i));
|
|
|
|
+
|
|
|
|
+ Terms subTermsAgg = bucket.getAggregations().get("subTerms");
|
|
|
|
+ assertThat(subTermsAgg, notNullValue());
|
|
|
|
+ assertThat(subTermsAgg.getBuckets().size(), equalTo(2));
|
|
|
|
+ int j = i;
|
|
|
|
+ for (Terms.Bucket subBucket : subTermsAgg.getBuckets()) {
|
|
|
|
+ assertThat(subBucket, notNullValue());
|
|
|
|
+ assertThat(key(subBucket), equalTo("val" + j));
|
|
|
|
+ assertThat(subBucket.getDocCount(), equalTo(1l));
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void indexMetaField() throws Exception {
|
|
public void indexMetaField() throws Exception {
|
|
SearchResponse response = client().prepareSearch("idx", "empty_bucket_idx").setTypes("type")
|
|
SearchResponse response = client().prepareSearch("idx", "empty_bucket_idx").setTypes("type")
|
|
.addAggregation(terms("terms")
|
|
.addAggregation(terms("terms")
|
|
|
|
+ .collectMode(randomFrom(SubAggCollectionMode.values()))
|
|
.executionHint(randomExecutionHint())
|
|
.executionHint(randomExecutionHint())
|
|
.field(IndexFieldMapper.NAME)
|
|
.field(IndexFieldMapper.NAME)
|
|
).execute().actionGet();
|
|
).execute().actionGet();
|