|
@@ -35,7 +35,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
|
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
|
|
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.PipelineTree;
|
|
|
import org.elasticsearch.search.aggregations.support.AggregationContext;
|
|
|
-import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
|
|
import org.hamcrest.Matcher;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -75,17 +74,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
"2016-03-04T17:09:50",
|
|
|
"2017-12-12T22:55:46");
|
|
|
|
|
|
- public void testMatchNoDocsDeprecatedInterval() throws IOException {
|
|
|
- testSearchCase(new MatchNoDocsQuery(), DATASET,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE),
|
|
|
- histogram -> {
|
|
|
- assertEquals(0, histogram.getBuckets().size());
|
|
|
- assertFalse(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testBooleanFieldDeprecated() throws IOException {
|
|
|
final String fieldName = "bogusBoolean";
|
|
|
testCase(
|
|
@@ -113,26 +101,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testMatchAllDocsDeprecatedInterval() throws IOException {
|
|
|
- Query query = new MatchAllDocsQuery();
|
|
|
-
|
|
|
- testSearchCase(query, DATASET,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE),
|
|
|
- histogram -> {
|
|
|
- assertEquals(8, histogram.getBuckets().size());
|
|
|
- assertTrue(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false
|
|
|
- );
|
|
|
- testSearchCase(query, DATASET,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE).minDocCount(1L),
|
|
|
- histogram -> {
|
|
|
- assertEquals(6, histogram.getBuckets().size());
|
|
|
- assertTrue(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testMatchAllDocs() throws IOException {
|
|
|
Query query = new MatchAllDocsQuery();
|
|
|
|
|
@@ -206,23 +174,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public void testNoDocsDeprecatedInterval() throws IOException {
|
|
|
- Query query = new MatchNoDocsQuery();
|
|
|
- List<String> dates = Collections.emptyList();
|
|
|
- Consumer<DateHistogramAggregationBuilder> aggregation =
|
|
|
- agg -> agg.dateHistogramInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE);
|
|
|
-
|
|
|
- testSearchCase(query, dates, aggregation, histogram -> {
|
|
|
- assertEquals(0, histogram.getBuckets().size());
|
|
|
- assertFalse(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false);
|
|
|
- testSearchCase(query, dates, aggregation, histogram -> {
|
|
|
- assertEquals(0, histogram.getBuckets().size());
|
|
|
- assertFalse(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false);
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testNoDocs() throws IOException {
|
|
|
Query query = new MatchNoDocsQuery();
|
|
|
List<String> dates = Collections.emptyList();
|
|
@@ -245,17 +196,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testAggregateWrongFieldDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(), DATASET,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.YEAR).field("wrong_field"),
|
|
|
- histogram -> {
|
|
|
- assertEquals(0, histogram.getBuckets().size());
|
|
|
- assertFalse(AggregationInspectionHelper.hasValue(histogram));
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testAggregateWrongField() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(), DATASET,
|
|
|
aggregation -> aggregation.calendarInterval(DateHistogramInterval.YEAR).field("wrong_field"),
|
|
@@ -267,29 +207,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalYearDeprecated() throws IOException {
|
|
|
- testSearchCase(LongPoint.newRangeQuery(SEARCHABLE_DATE, asLong("2015-01-01"), asLong("2017-12-31")), DATASET,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(3, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2015-01-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2016-01-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-01-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalYear() throws IOException {
|
|
|
testSearchCase(LongPoint.newRangeQuery(SEARCHABLE_DATE, asLong("2015-01-01"), asLong("2017-12-31")), DATASET,
|
|
|
aggregation -> aggregation.calendarInterval(DateHistogramInterval.YEAR).field(AGGREGABLE_DATE),
|
|
@@ -312,30 +229,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalMonthDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList("2017-01-01", "2017-02-02", "2017-02-03", "2017-03-04", "2017-03-05", "2017-03-06"),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.MONTH).field(AGGREGABLE_DATE),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(3, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-01-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-03-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalMonth() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList("2017-01-01", "2017-02-02", "2017-02-03", "2017-03-04", "2017-03-05", "2017-03-06"),
|
|
@@ -359,42 +252,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalDayDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.DAY).field(AGGREGABLE_DATE).minDocCount(1L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(4, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-02T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-02-03T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(3);
|
|
|
- assertEquals("2017-02-05T00:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalDay() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList(
|
|
@@ -462,53 +319,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalHourDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01T09:02:00.000Z",
|
|
|
- "2017-02-01T09:35:00.000Z",
|
|
|
- "2017-02-01T10:15:00.000Z",
|
|
|
- "2017-02-01T13:06:00.000Z",
|
|
|
- "2017-02-01T14:04:00.000Z",
|
|
|
- "2017-02-01T14:05:00.000Z",
|
|
|
- "2017-02-01T15:59:00.000Z",
|
|
|
- "2017-02-01T16:06:00.000Z",
|
|
|
- "2017-02-01T16:48:00.000Z",
|
|
|
- "2017-02-01T16:59:00.000Z"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.HOUR).field(AGGREGABLE_DATE).minDocCount(1L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(6, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T09:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-01T10:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-02-01T13:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(3);
|
|
|
- assertEquals("2017-02-01T14:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(4);
|
|
|
- assertEquals("2017-02-01T15:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(5);
|
|
|
- assertEquals("2017-02-01T16:00:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalHour() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList(
|
|
@@ -598,36 +408,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalMinuteDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01T09:02:35.000Z",
|
|
|
- "2017-02-01T09:02:59.000Z",
|
|
|
- "2017-02-01T09:15:37.000Z",
|
|
|
- "2017-02-01T09:16:04.000Z",
|
|
|
- "2017-02-01T09:16:42.000Z"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.MINUTE).field(AGGREGABLE_DATE).minDocCount(1L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(3, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T09:02:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-01T09:15:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-02-01T09:16:00.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalMinute() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList(
|
|
@@ -683,37 +463,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testIntervalSecondDeprecated() throws IOException {
|
|
|
- testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01T00:00:05.015Z",
|
|
|
- "2017-02-01T00:00:11.299Z",
|
|
|
- "2017-02-01T00:00:11.074Z",
|
|
|
- "2017-02-01T00:00:37.688Z",
|
|
|
- "2017-02-01T00:00:37.210Z",
|
|
|
- "2017-02-01T00:00:37.380Z"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.SECOND).field(AGGREGABLE_DATE).minDocCount(1L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(3, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T00:00:05.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-01T00:00:11.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(2, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-02-01T00:00:37.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testIntervalSecond() throws IOException {
|
|
|
testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList(
|
|
@@ -828,56 +577,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public void testMinDocCountDeprecated() throws IOException {
|
|
|
- Query query = LongPoint.newRangeQuery(SEARCHABLE_DATE, asLong("2017-02-01T00:00:00.000Z"), asLong("2017-02-01T00:00:30.000Z"));
|
|
|
- List<String> timestamps = Arrays.asList(
|
|
|
- "2017-02-01T00:00:05.015Z",
|
|
|
- "2017-02-01T00:00:11.299Z",
|
|
|
- "2017-02-01T00:00:11.074Z",
|
|
|
- "2017-02-01T00:00:13.688Z",
|
|
|
- "2017-02-01T00:00:21.380Z"
|
|
|
- );
|
|
|
-
|
|
|
- // 5 sec interval with minDocCount = 0
|
|
|
- testSearchCase(query, timestamps,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.seconds(5)).field(AGGREGABLE_DATE).minDocCount(0L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(4, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T00:00:05.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(1);
|
|
|
- assertEquals("2017-02-01T00:00:10.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(2);
|
|
|
- assertEquals("2017-02-01T00:00:15.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(0, bucket.getDocCount());
|
|
|
-
|
|
|
- bucket = buckets.get(3);
|
|
|
- assertEquals("2017-02-01T00:00:20.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(1, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
-
|
|
|
- // 5 sec interval with minDocCount = 3
|
|
|
- testSearchCase(query, timestamps,
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.seconds(5)).field(AGGREGABLE_DATE).minDocCount(3L),
|
|
|
- histogram -> {
|
|
|
- List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
|
|
|
- assertEquals(1, buckets.size());
|
|
|
-
|
|
|
- Histogram.Bucket bucket = buckets.get(0);
|
|
|
- assertEquals("2017-02-01T00:00:10.000Z", bucket.getKeyAsString());
|
|
|
- assertEquals(3, bucket.getDocCount());
|
|
|
- }, false
|
|
|
- );
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
public void testMinDocCount() throws IOException {
|
|
|
Query query = LongPoint.newRangeQuery(SEARCHABLE_DATE, asLong("2017-02-01T00:00:00.000Z"), asLong("2017-02-01T00:00:30.000Z"));
|
|
|
List<String> timestamps = Arrays.asList(
|
|
@@ -1000,149 +699,6 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
assertThat(e.getMessage(), equalTo("Cannot use [calendar_interval] with [fixed_interval] configuration option."));
|
|
|
}
|
|
|
|
|
|
- public void testNewThenLegacy() throws IOException {
|
|
|
- IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.fixedInterval(new DateHistogramInterval("2d"))
|
|
|
- .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [interval] with [fixed_interval] or [calendar_interval] configuration options."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.calendarInterval(DateHistogramInterval.DAY)
|
|
|
- .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [interval] with [fixed_interval] or [calendar_interval] configuration options."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.fixedInterval(new DateHistogramInterval("2d"))
|
|
|
- .interval(1000)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [interval] with [fixed_interval] or [calendar_interval] configuration options."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.calendarInterval(DateHistogramInterval.DAY)
|
|
|
- .interval(1000)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [interval] with [fixed_interval] or [calendar_interval] configuration options."));
|
|
|
- }
|
|
|
-
|
|
|
- public void testLegacyThenNew() throws IOException {
|
|
|
- IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
- .fixedInterval(new DateHistogramInterval("2d"))
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [fixed_interval] with [interval] configuration option."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
- .calendarInterval(DateHistogramInterval.DAY)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [calendar_interval] with [interval] configuration option."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.interval(1000)
|
|
|
- .fixedInterval(new DateHistogramInterval("2d"))
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [fixed_interval] with [interval] configuration option."));
|
|
|
-
|
|
|
- e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Arrays.asList(
|
|
|
- "2017-02-01",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-02",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-03",
|
|
|
- "2017-02-05"
|
|
|
- ),
|
|
|
- aggregation -> aggregation.interval(1000)
|
|
|
- .calendarInterval(DateHistogramInterval.DAY)
|
|
|
- .field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Cannot use [calendar_interval] with [interval] configuration option."));
|
|
|
-
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public void testOverlappingBounds() {
|
|
|
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
Arrays.asList(
|
|
@@ -1338,13 +894,35 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
|
|
|
}
|
|
|
|
|
|
public void testIllegalInterval() throws IOException {
|
|
|
- IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testSearchCase(new MatchAllDocsQuery(),
|
|
|
- Collections.emptyList(),
|
|
|
- aggregation -> aggregation.dateHistogramInterval(new DateHistogramInterval("foobar")).field(AGGREGABLE_DATE),
|
|
|
- histogram -> {}, false
|
|
|
- ));
|
|
|
- assertThat(e.getMessage(), equalTo("Unable to parse interval [foobar]"));
|
|
|
- assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future.");
|
|
|
+ IllegalArgumentException e = expectThrows(
|
|
|
+ IllegalArgumentException.class,
|
|
|
+ () -> testSearchCase(
|
|
|
+ new MatchAllDocsQuery(),
|
|
|
+ Collections.emptyList(),
|
|
|
+ aggregation -> aggregation.calendarInterval(new DateHistogramInterval("foobar")).field(AGGREGABLE_DATE),
|
|
|
+ histogram -> {},
|
|
|
+ false
|
|
|
+ )
|
|
|
+ );
|
|
|
+ assertThat(e.getMessage(), equalTo("The supplied interval [foobar] could not be parsed as a calendar interval."));
|
|
|
+
|
|
|
+ e = expectThrows(
|
|
|
+ IllegalArgumentException.class,
|
|
|
+ () -> testSearchCase(
|
|
|
+ new MatchAllDocsQuery(),
|
|
|
+ Collections.emptyList(),
|
|
|
+ aggregation -> aggregation.fixedInterval(new DateHistogramInterval("foobar")).field(AGGREGABLE_DATE),
|
|
|
+ histogram -> {},
|
|
|
+ false
|
|
|
+ )
|
|
|
+ );
|
|
|
+ assertThat(
|
|
|
+ e.getMessage(),
|
|
|
+ equalTo(
|
|
|
+ "failed to parse setting [date_histogram.fixedInterval] with value [foobar] as a time value:"
|
|
|
+ + " unit is missing or unrecognized"
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testBuildEmpty() throws IOException {
|