Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions docs/reference/aggregations/bucket/range-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -379,30 +379,3 @@ Response:
}
--------------------------------------------------
// TESTRESPONSE[s/\.\.\.//]

If a sub aggregation is also based on the same value source as the range aggregation (like the `stats` aggregation in the example above) it is possible to leave out the value source definition for it. The following will return the same response as above:

[source,console,id=range-aggregation-sub-aggregation-empty-example]
--------------------------------------------------
GET /_search
{
"aggs" : {
"price_ranges" : {
"range" : {
"field" : "price",
"ranges" : [
{ "to" : 100 },
{ "from" : 100, "to" : 200 },
{ "from" : 200 }
]
},
"aggs" : {
"price_stats" : {
"stats" : {} <1>
}
}
}
}
}
--------------------------------------------------
<1> We don't need to specify the `price` as we "inherit" it by default from the parent `range` aggregation
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,18 @@ setup:

- gt: { indices.test_1.total.fielddata.memory_size_in_bytes: 0}

---
"No field or script":
- skip:
version: "all" # TODO change this after backport
reason: "Exception was a deep, server exception before 7.8"
- do:
catch: /Required one of fields \[field, script\], but none were specified/
search:
rest_total_hits_as_int: true
index: test_1
body: { "size" : 0, "aggs" : { "no_field_terms" : { "terms" : { "size": 1 } } } }




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public static <T> void declareFields(
objectParser.declareField(ValuesSourceAggregationBuilder::script,
(parser, context) -> Script.parse(parser),
Script.SCRIPT_PARSE_FIELD, ObjectParser.ValueType.OBJECT_OR_STRING);
String[] fields = new String[]{ParseField.CommonFields.FIELD.getPreferredName(), Script.SCRIPT_PARSE_FIELD.getPreferredName()};
objectParser.declareRequiredFieldSet(fields);
} else {
objectParser.declareRequiredFieldSet(ParseField.CommonFields.FIELD.getPreferredName());
}

if (timezoneAware) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ private static AggregationBuilder getRandomAggregation() {
final int randomAggregatorPoolSize = 4;
switch (randomIntBetween(1, randomAggregatorPoolSize)) {
case 1:
return AggregationBuilders.avg(randomAlphaOfLengthBetween(3, 10));
return AggregationBuilders.avg(randomAlphaOfLengthBetween(3, 10)).field("foo");
case 2:
return AggregationBuilders.min(randomAlphaOfLengthBetween(3, 10));
return AggregationBuilders.min(randomAlphaOfLengthBetween(3, 10)).field("foo");
case 3:
return AggregationBuilders.max(randomAlphaOfLengthBetween(3, 10));
return AggregationBuilders.max(randomAlphaOfLengthBetween(3, 10)).field("foo");
case 4:
return AggregationBuilders.sum(randomAlphaOfLengthBetween(3, 10));
return AggregationBuilders.sum(randomAlphaOfLengthBetween(3, 10)).field("foo");
}

// never reached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class GeoHashGridTests extends BaseAggregationTestCase<GeoGridAggregation
protected GeoHashGridAggregationBuilder createTestAggregatorBuilder() {
String name = randomAlphaOfLengthBetween(3, 20);
GeoHashGridAggregationBuilder factory = new GeoHashGridAggregationBuilder(name);
factory.field("foo");
if (randomBoolean()) {
int precision = randomIntBetween(1, 12);
factory.precision(precision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GeoTileGridTests extends BaseAggregationTestCase<GeoGridAggregation
protected GeoTileGridAggregationBuilder createTestAggregatorBuilder() {
String name = randomAlphaOfLengthBetween(3, 20);
GeoTileGridAggregationBuilder factory = new GeoTileGridAggregationBuilder(name);
factory.field("foo");
if (randomBoolean()) {
factory.precision(randomIntBetween(0, GeoTileUtils.MAX_ZOOM));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public static SearchSourceBuilder randomSearchSourceBuilder(
}
}
if (randomBoolean()) {
builder.aggregation(AggregationBuilders.avg(randomAlphaOfLengthBetween(5, 20)));
builder.aggregation(AggregationBuilders.avg(randomAlphaOfLengthBetween(5, 20)).field("foo"));
}
if (randomBoolean()) {
builder.ext(randomExtBuilders.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected Reader<StringStatsAggregationBuilder> instanceReader() {
@Override
protected StringStatsAggregationBuilder createTestInstance() {
StringStatsAggregationBuilder builder = new StringStatsAggregationBuilder(randomAlphaOfLength(5));
builder.field("foo");
builder.showDistribution(randomBoolean());
return builder;
}
Expand Down Expand Up @@ -92,6 +93,8 @@ private org.elasticsearch.client.analytics.StringStatsAggregationBuilder createC
StringStatsAggregationBuilder serverBuilder) {
org.elasticsearch.client.analytics.StringStatsAggregationBuilder builder =
new org.elasticsearch.client.analytics.StringStatsAggregationBuilder(serverBuilder.getName());
return builder.showDistribution(serverBuilder.showDistribution());
return builder
.showDistribution(serverBuilder.showDistribution())
.field(serverBuilder.field());
}
}