Skip to content

Commit 5d9c3a2

Browse files
authored
Remove date histogram boolean support (#118484)
This removes support for running date aggregations over boolean fields. This has never been useful, was deprecated in 7.x, and is finally being disabled for 9.0.
1 parent ae3c0d7 commit 5d9c3a2

File tree

4 files changed

+19
-48
lines changed

4 files changed

+19
-48
lines changed

build-tools-internal/src/main/resources/changelog-schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@
279279
"compatibilityChangeArea": {
280280
"type": "string",
281281
"enum": [
282+
"Aggregations",
282283
"Analysis",
283284
"Authorization",
284285
"Cluster and node setting",

docs/changelog/118484.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pr: 118484
2+
summary: Remove date histogram boolean support
3+
area: Aggregations
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Remove date histogram boolean support
8+
area: Aggregations
9+
details: Elasticsearch no longer allows running Date Histogram aggregations
10+
over boolean fields. Instead, use Terms aggregation for boolean
11+
fields.
12+
impact: We expect the impact to be minimal, as this never produced good
13+
results, and has been deprecated for years.
14+
notable: false

server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.ElasticsearchStatusException;
1313
import org.elasticsearch.common.Rounding;
14-
import org.elasticsearch.common.logging.DeprecationCategory;
1514
import org.elasticsearch.common.logging.DeprecationLogger;
1615
import org.elasticsearch.rest.RestStatus;
1716
import org.elasticsearch.search.aggregations.Aggregator;
@@ -42,49 +41,6 @@ public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
4241
);
4342

4443
builder.register(DateHistogramAggregationBuilder.REGISTRY_KEY, CoreValuesSourceType.RANGE, DateRangeHistogramAggregator::new, true);
45-
46-
builder.register(
47-
DateHistogramAggregationBuilder.REGISTRY_KEY,
48-
CoreValuesSourceType.BOOLEAN,
49-
(
50-
name,
51-
factories,
52-
rounding,
53-
order,
54-
keyed,
55-
minDocCount,
56-
downsampledResultsOffset,
57-
extendedBounds,
58-
hardBounds,
59-
valuesSourceConfig,
60-
context,
61-
parent,
62-
cardinality,
63-
metadata) -> {
64-
DEPRECATION_LOGGER.warn(
65-
DeprecationCategory.AGGREGATIONS,
66-
"date-histogram-boolean",
67-
"Running DateHistogram aggregations on [boolean] fields is deprecated"
68-
);
69-
return DateHistogramAggregator.build(
70-
name,
71-
factories,
72-
rounding,
73-
order,
74-
keyed,
75-
minDocCount,
76-
downsampledResultsOffset,
77-
extendedBounds,
78-
hardBounds,
79-
valuesSourceConfig,
80-
context,
81-
parent,
82-
cardinality,
83-
metadata
84-
);
85-
},
86-
true
87-
);
8844
}
8945

9046
private final DateHistogramAggregationSupplier aggregatorSupplier;

server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
8383
"2017-12-12T22:55:46"
8484
);
8585

86-
public void testBooleanFieldDeprecated() throws IOException {
86+
public void testBooleanFieldUnsupported() throws IOException {
8787
final String fieldName = "bogusBoolean";
88-
testCase(iw -> {
88+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testCase(iw -> {
8989
Document d = new Document();
9090
d.add(new SortedNumericDocValuesField(fieldName, 0));
9191
iw.addDocument(d);
@@ -95,8 +95,8 @@ public void testBooleanFieldDeprecated() throws IOException {
9595
new DateHistogramAggregationBuilder("name").calendarInterval(DateHistogramInterval.HOUR).field(fieldName),
9696
new BooleanFieldMapper.BooleanFieldType(fieldName)
9797
)
98-
);
99-
assertWarnings("Running DateHistogram aggregations on [boolean] fields is deprecated");
98+
));
99+
assertThat(e.getMessage(), equalTo("Field [bogusBoolean] of type [boolean] is not supported for aggregation [date_histogram]"));
100100
}
101101

102102
public void testMatchNoDocs() throws IOException {

0 commit comments

Comments
 (0)