Search in sources :

Example 1 with MatchNoneQueryBuilder

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());
}
Also used : KeyedFilter(org.elasticsearch.search.aggregations.bucket.filters.FiltersAggregator.KeyedFilter) MatchNoneQueryBuilder(org.elasticsearch.index.query.MatchNoneQueryBuilder) FiltersAggregationBuilder(org.elasticsearch.search.aggregations.bucket.filters.FiltersAggregationBuilder)

Example 2 with MatchNoneQueryBuilder

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();
}
Also used : MatchNoneQueryBuilder(org.elasticsearch.index.query.MatchNoneQueryBuilder) AdjacencyMatrixAggregationBuilder(org.elasticsearch.search.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder) HashMap(java.util.HashMap) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) MatchNoneQueryBuilder(org.elasticsearch.index.query.MatchNoneQueryBuilder)

Example 3 with MatchNoneQueryBuilder

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));
}
Also used : MatchNoneQueryBuilder(org.elasticsearch.index.query.MatchNoneQueryBuilder) ExtendedBounds(org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds) Histogram(org.elasticsearch.search.aggregations.bucket.histogram.Histogram) AggregationBuilders.dateHistogram(org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram) DateTime(org.joda.time.DateTime) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Aggregations

MatchNoneQueryBuilder (org.elasticsearch.index.query.MatchNoneQueryBuilder)3 HashMap (java.util.HashMap)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)1 AggregationBuilders.dateHistogram (org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram)1 AdjacencyMatrixAggregationBuilder (org.elasticsearch.search.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder)1 FiltersAggregationBuilder (org.elasticsearch.search.aggregations.bucket.filters.FiltersAggregationBuilder)1 KeyedFilter (org.elasticsearch.search.aggregations.bucket.filters.FiltersAggregator.KeyedFilter)1 ExtendedBounds (org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds)1 Histogram (org.elasticsearch.search.aggregations.bucket.histogram.Histogram)1 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)1 DateTime (org.joda.time.DateTime)1