diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java index c8944aafb69..7278c9c07db 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java @@ -56,6 +56,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -97,10 +98,10 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(prepareCreate("idx").addMapping("type", "_timestamp", "enabled=true")); createIndex("idx_unmapped"); // TODO: would be nice to have more random data here - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").execute().actionGet(); + assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add(client().prepareIndex("empty_bucket_idx", "type", ""+i).setSource(jsonBuilder() @@ -1314,4 +1315,12 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { assertThat(e.toString(), containsString("ElasticsearchParseException")); } } + + @AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/pull/11482") + public void testTimestampField() { + SearchResponse response = client().prepareSearch("idx").addAggregation(dateHistogram("histo").field("_timestamp").interval(randomFrom(DateHistogramInterval.DAY, DateHistogramInterval.MONTH))).get(); + assertSearchResponse(response); + Histogram histo = response.getAggregations().get("histo"); + assertThat(histo.getBuckets().size(), greaterThan(0)); + } }