Search in sources :

Example 21 with SearchQuery

use of io.druid.query.search.search.SearchQuery in project druid by druid-io.

the class SearchQueryRunnerTest method testSearchSameValueInMultiDims.

@Test
public void testSearchSameValueInMultiDims() {
    SearchQuery searchQuery = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).dimensions(Arrays.asList(QueryRunnerTestHelper.placementDimension, QueryRunnerTestHelper.placementishDimension)).query("e").build();
    List<SearchHit> expectedHits = Lists.newLinkedList();
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementDimension, "preferred", 1209));
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementishDimension, "e", 93));
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementishDimension, "preferred", 1209));
    checkSearchQuery(searchQuery, expectedHits);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) Test(org.junit.Test)

Example 22 with SearchQuery

use of io.druid.query.search.search.SearchQuery in project druid by druid-io.

the class SearchQueryRunnerTest method testSearchWithExtractionFilter1.

@Test
public void testSearchWithExtractionFilter1() {
    final String automotiveSnowman = "automotive☃";
    List<SearchHit> expectedHits = Lists.newLinkedList();
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.qualityDimension, automotiveSnowman, 93));
    final LookupExtractionFn lookupExtractionFn = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("automotive", automotiveSnowman), false), true, null, true, true);
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).filters(new ExtractionDimFilter(QueryRunnerTestHelper.qualityDimension, automotiveSnowman, lookupExtractionFn, null)).intervals(QueryRunnerTestHelper.fullOnInterval).dimensions(new ExtractionDimensionSpec(QueryRunnerTestHelper.qualityDimension, null, lookupExtractionFn)).query("☃").build();
    checkSearchQuery(query, expectedHits);
}
Also used : LookupExtractionFn(io.druid.query.lookup.LookupExtractionFn) SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) MapLookupExtractor(io.druid.query.extraction.MapLookupExtractor) ExtractionDimFilter(io.druid.query.filter.ExtractionDimFilter) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 23 with SearchQuery

use of io.druid.query.search.search.SearchQuery in project druid by druid-io.

the class SearchQueryRunnerWithCaseTest method testSearchIntervals.

@Test
public void testSearchIntervals() {
    SearchQuery searchQuery;
    Druids.SearchQueryBuilder builder = testBuilder().dimensions(Arrays.asList(qualityDimension)).intervals("2011-01-12T00:00:00.000Z/2011-01-13T00:00:00.000Z");
    Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    searchQuery = builder.query("otive").build();
    expectedResults.put(qualityDimension, Sets.newHashSet("AutoMotive"));
    checkSearchQuery(searchQuery, expectedResults);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) Set(java.util.Set) Druids(io.druid.query.Druids) Test(org.junit.Test)

Example 24 with SearchQuery

use of io.druid.query.search.search.SearchQuery in project druid by druid-io.

the class SearchQueryRunnerWithCaseTest method testSearchNoOverrappingIntervals.

@Test
public void testSearchNoOverrappingIntervals() {
    SearchQuery searchQuery;
    Druids.SearchQueryBuilder builder = testBuilder().dimensions(Arrays.asList(qualityDimension)).intervals("2011-01-10T00:00:00.000Z/2011-01-11T00:00:00.000Z");
    Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    searchQuery = builder.query("business").build();
    expectedResults.put(qualityDimension, Sets.<String>newHashSet());
    checkSearchQuery(searchQuery, expectedResults);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) Set(java.util.Set) Druids(io.druid.query.Druids) Test(org.junit.Test)

Example 25 with SearchQuery

use of io.druid.query.search.search.SearchQuery in project druid by druid-io.

the class SearchQueryRunnerTest method testSearchWithNotExistedDimension.

@Test
public void testSearchWithNotExistedDimension() throws Exception {
    SearchQuery searchQuery = Druids.newSearchQueryBuilder().dimensions(new DefaultDimensionSpec("asdf", "asdf")).dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).build();
    List<SearchHit> noHit = Lists.newLinkedList();
    checkSearchQuery(searchQuery, noHit);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) Test(org.junit.Test)

Aggregations

SearchQuery (io.druid.query.search.search.SearchQuery)31 Test (org.junit.Test)25 SearchHit (io.druid.query.search.search.SearchHit)22 Result (io.druid.query.Result)12 SearchResultValue (io.druid.query.search.SearchResultValue)9 HashMap (java.util.HashMap)9 QueryRunner (io.druid.query.QueryRunner)8 DateTime (org.joda.time.DateTime)8 Druids (io.druid.query.Druids)5 Set (java.util.Set)5 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)4 ExtractionDimensionSpec (io.druid.query.dimension.ExtractionDimensionSpec)4 Interval (org.joda.time.Interval)4 TimeFormatExtractionFn (io.druid.query.extraction.TimeFormatExtractionFn)3 LookupExtractionFn (io.druid.query.lookup.LookupExtractionFn)3 MultipleIntervalSegmentSpec (io.druid.query.spec.MultipleIntervalSegmentSpec)3 Map (java.util.Map)3 Function (com.google.common.base.Function)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ISE (io.druid.java.util.common.ISE)2