diff options
author | Tanguy Leroux <tlrx.dev@gmail.com> | 2017-05-19 13:13:00 +0200 |
---|---|---|
committer | Tanguy Leroux <tlrx.dev@gmail.com> | 2017-05-19 13:13:00 +0200 |
commit | 83aa00b3f665099b0f5dadf5a2fcd97219cdbde5 (patch) | |
tree | 04253d353603d3caa4098c09d870409564a7d4d1 /core/src/test/java/org/elasticsearch/search | |
parent | 4c34ea8fc84ccd27af98b81f51408fcb53077a20 (diff) | |
parent | 55af1f7a2b503d7997b476c34f952bd9fce6eeb5 (diff) |
Merge remote-tracking branch 'origin/master' into feature/client_aggs_parsing
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search')
4 files changed, 58 insertions, 12 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java index 283f964b68..db5a0a1cd8 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java @@ -1162,7 +1162,61 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket.getDocCount(), equalTo(0L)); } } - internalCluster().wipeIndices("test12278"); + internalCluster().wipeIndices(index); + } + + /** + * Test date histogram aggregation with day interval, offset and + * extended bounds (see https://github.com/elastic/elasticsearch/issues/23776) + */ + public void testSingleValueFieldWithExtendedBoundsOffset() throws Exception { + String index = "test23776"; + prepareCreate(index) + .setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) + .execute().actionGet(); + + List<IndexRequestBuilder> builders = new ArrayList<>(); + builders.add(indexDoc(index, DateTime.parse("2016-01-03T08:00:00.000Z"), 1)); + builders.add(indexDoc(index, DateTime.parse("2016-01-03T08:00:00.000Z"), 2)); + builders.add(indexDoc(index, DateTime.parse("2016-01-06T08:00:00.000Z"), 3)); + builders.add(indexDoc(index, DateTime.parse("2016-01-06T08:00:00.000Z"), 4)); + indexRandom(true, builders); + ensureSearchable(index); + + SearchResponse response = null; + // retrieve those docs with the same time zone and extended bounds + response = client() + .prepareSearch(index) + .addAggregation( + dateHistogram("histo").field("date").dateHistogramInterval(DateHistogramInterval.days(1)).offset("+6h").minDocCount(0) + .extendedBounds(new ExtendedBounds("2016-01-01T06:00:00Z", "2016-01-08T08:00:00Z")) + ).execute().actionGet(); + assertSearchResponse(response); + + Histogram histo = response.getAggregations().get("histo"); + assertThat(histo, notNullValue()); + assertThat(histo.getName(), equalTo("histo")); + List<? extends Bucket> buckets = histo.getBuckets(); + assertThat(buckets.size(), equalTo(8)); + + assertEquals("2016-01-01T06:00:00.000Z", buckets.get(0).getKeyAsString()); + assertEquals(0, buckets.get(0).getDocCount()); + assertEquals("2016-01-02T06:00:00.000Z", buckets.get(1).getKeyAsString()); + assertEquals(0, buckets.get(1).getDocCount()); + assertEquals("2016-01-03T06:00:00.000Z", buckets.get(2).getKeyAsString()); + assertEquals(2, buckets.get(2).getDocCount()); + assertEquals("2016-01-04T06:00:00.000Z", buckets.get(3).getKeyAsString()); + assertEquals(0, buckets.get(3).getDocCount()); + assertEquals("2016-01-05T06:00:00.000Z", buckets.get(4).getKeyAsString()); + assertEquals(0, buckets.get(4).getDocCount()); + assertEquals("2016-01-06T06:00:00.000Z", buckets.get(5).getKeyAsString()); + assertEquals(2, buckets.get(5).getDocCount()); + assertEquals("2016-01-07T06:00:00.000Z", buckets.get(6).getKeyAsString()); + assertEquals(0, buckets.get(6).getDocCount()); + assertEquals("2016-01-08T06:00:00.000Z", buckets.get(7).getKeyAsString()); + assertEquals(0, buckets.get(7).getDocCount()); + + internalCluster().wipeIndices(index); } public void testSingleValueWithMultipleDateFormatsFromMapping() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java index 33ba2684f7..093dab2f4f 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContextRegistry; import org.elasticsearch.script.ScriptEngineRegistry; import org.elasticsearch.script.ScriptService; -import org.elasticsearch.script.ScriptSettings; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.aggregations.ParsedAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; @@ -122,10 +121,8 @@ public class InternalScriptedMetricTests extends InternalAggregationTestCase<Int })); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(scriptEngine)); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList()); - ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); try { - return new ScriptService(Settings.EMPTY, scriptEngineRegistry, scriptContextRegistry, - scriptSettings); + return new ScriptService(Settings.EMPTY, scriptEngineRegistry, scriptContextRegistry); } catch (IOException e) { throw new ElasticsearchException(e); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorTests.java index 58487a715e..441be5b0e8 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorTests.java @@ -38,7 +38,6 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContextRegistry; import org.elasticsearch.script.ScriptEngineRegistry; import org.elasticsearch.script.ScriptService; -import org.elasticsearch.script.ScriptSettings; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.aggregations.AggregatorTestCase; import org.junit.BeforeClass; @@ -201,10 +200,9 @@ public class ScriptedMetricAggregatorTests extends AggregatorTestCase { MockScriptEngine scriptEngine = new MockScriptEngine(MockScriptEngine.NAME, SCRIPTS); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(scriptEngine)); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList()); - ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); ScriptService scriptService; try { - scriptService = new ScriptService(Settings.EMPTY, scriptEngineRegistry, scriptContextRegistry, scriptSettings); + scriptService = new ScriptService(Settings.EMPTY, scriptEngineRegistry, scriptContextRegistry); } catch (IOException e) { throw new ElasticsearchException(e); } diff --git a/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java b/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java index ee671ca3d0..83a3cf8514 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java @@ -57,7 +57,6 @@ import org.elasticsearch.script.ScriptContextRegistry; import org.elasticsearch.script.ScriptEngineRegistry; import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptServiceTests.TestEngine; -import org.elasticsearch.script.ScriptSettings; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.SearchModule; @@ -89,11 +88,9 @@ public abstract class AbstractSortTestCase<T extends SortBuilder<T>> extends EST .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .put(Environment.PATH_CONF_SETTING.getKey(), genericConfigFolder) .build(); - Environment environment = new Environment(baseSettings); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList()); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new TestEngine())); - ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); - scriptService = new ScriptService(baseSettings, scriptEngineRegistry, scriptContextRegistry, scriptSettings) { + scriptService = new ScriptService(baseSettings, scriptEngineRegistry, scriptContextRegistry) { @Override public CompiledScript compile(Script script, ScriptContext scriptContext) { return new CompiledScript(ScriptType.INLINE, "mockName", "test", script); |