Skip to content

Commit

Permalink
Remove date histogram boolean support (elastic#118484)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
not-napoleon authored Dec 17, 2024
1 parent ae3c0d7 commit 5d9c3a2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
"compatibilityChangeArea": {
"type": "string",
"enum": [
"Aggregations",
"Analysis",
"Authorization",
"Cluster and node setting",
Expand Down
14 changes: 14 additions & 0 deletions docs/changelog/118484.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pr: 118484
summary: Remove date histogram boolean support
area: Aggregations
type: breaking
issues: []
breaking:
title: Remove date histogram boolean support
area: Aggregations
details: Elasticsearch no longer allows running Date Histogram aggregations
over boolean fields. Instead, use Terms aggregation for boolean
fields.
impact: We expect the impact to be minimal, as this never produced good
results, and has been deprecated for years.
notable: false
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.aggregations.Aggregator;
Expand Down Expand Up @@ -42,49 +41,6 @@ public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
);

builder.register(DateHistogramAggregationBuilder.REGISTRY_KEY, CoreValuesSourceType.RANGE, DateRangeHistogramAggregator::new, true);

builder.register(
DateHistogramAggregationBuilder.REGISTRY_KEY,
CoreValuesSourceType.BOOLEAN,
(
name,
factories,
rounding,
order,
keyed,
minDocCount,
downsampledResultsOffset,
extendedBounds,
hardBounds,
valuesSourceConfig,
context,
parent,
cardinality,
metadata) -> {
DEPRECATION_LOGGER.warn(
DeprecationCategory.AGGREGATIONS,
"date-histogram-boolean",
"Running DateHistogram aggregations on [boolean] fields is deprecated"
);
return DateHistogramAggregator.build(
name,
factories,
rounding,
order,
keyed,
minDocCount,
downsampledResultsOffset,
extendedBounds,
hardBounds,
valuesSourceConfig,
context,
parent,
cardinality,
metadata
);
},
true
);
}

private final DateHistogramAggregationSupplier aggregatorSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
"2017-12-12T22:55:46"
);

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

public void testMatchNoDocs() throws IOException {
Expand Down

0 comments on commit 5d9c3a2

Please sign in to comment.