use of org.elasticsearch.index.query.MatchNoneQueryBuilder in project elasticsearch by elastic.
the class FiltersTests method testFiltersSortedByKey.
/**
* Test that when passing in keyed filters as list or array, the list stored internally is sorted by key
* Also check the list passed in is not modified by this but rather copied
*/
public void testFiltersSortedByKey() {
KeyedFilter[] original = new KeyedFilter[] { new KeyedFilter("bbb", new MatchNoneQueryBuilder()), new KeyedFilter("aaa", new MatchNoneQueryBuilder()) };
FiltersAggregationBuilder builder;
builder = new FiltersAggregationBuilder("my-agg", original);
assertEquals("aaa", builder.filters().get(0).key());
assertEquals("bbb", builder.filters().get(1).key());
// original should be unchanged
assertEquals("bbb", original[0].key());
assertEquals("aaa", original[1].key());
}
use of org.elasticsearch.index.query.MatchNoneQueryBuilder in project elasticsearch by elastic.
the class AdjacencyMatrixTests method testFiltersSameMap.
/**
* Test that when passing in keyed filters as a map they are equivalent
*/
public void testFiltersSameMap() {
Map<String, QueryBuilder> original = new HashMap<>();
original.put("bbb", new MatchNoneQueryBuilder());
original.put("aaa", new MatchNoneQueryBuilder());
AdjacencyMatrixAggregationBuilder builder;
builder = new AdjacencyMatrixAggregationBuilder("my-agg", original);
assertEquals(original, builder.filters());
assert original != builder.filters();
}
use of org.elasticsearch.index.query.MatchNoneQueryBuilder in project elasticsearch by elastic.
the class DateHistogramIT method testDSTEndTransition.
/**
* When DST ends, local time turns back one hour, so between 2am and 4am wall time we should have four buckets:
* "2015-10-25T02:00:00.000+02:00",
* "2015-10-25T02:00:00.000+01:00",
* "2015-10-25T03:00:00.000+01:00",
* "2015-10-25T04:00:00.000+01:00".
*/
public void testDSTEndTransition() throws Exception {
SearchResponse response = client().prepareSearch("idx").setQuery(new MatchNoneQueryBuilder()).addAggregation(dateHistogram("histo").field("date").timeZone(DateTimeZone.forID("Europe/Oslo")).dateHistogramInterval(DateHistogramInterval.HOUR).minDocCount(0).extendedBounds(new ExtendedBounds("2015-10-25T02:00:00.000+02:00", "2015-10-25T04:00:00.000+01:00"))).execute().actionGet();
Histogram histo = response.getAggregations().get("histo");
List<? extends Bucket> buckets = histo.getBuckets();
assertThat(buckets.size(), equalTo(4));
assertThat(((DateTime) buckets.get(1).getKey()).getMillis() - ((DateTime) buckets.get(0).getKey()).getMillis(), equalTo(3600000L));
assertThat(((DateTime) buckets.get(2).getKey()).getMillis() - ((DateTime) buckets.get(1).getKey()).getMillis(), equalTo(3600000L));
assertThat(((DateTime) buckets.get(3).getKey()).getMillis() - ((DateTime) buckets.get(2).getKey()).getMillis(), equalTo(3600000L));
}
Aggregations