Search in sources :

Example 6 with SearchQuery

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

the class SearchQueryRunnerTest method testSearchOnTime.

@Test
public void testSearchOnTime() {
    SearchQuery searchQuery = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).query("Friday").dimensions(new ExtractionDimensionSpec(Column.TIME_COLUMN_NAME, "__time2", new TimeFormatExtractionFn("EEEE", null, null, null, false))).build();
    List<SearchHit> expectedHits = Lists.newLinkedList();
    expectedHits.add(new SearchHit("__time2", "Friday", 169));
    checkSearchQuery(searchQuery, expectedHits);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) TimeFormatExtractionFn(io.druid.query.extraction.TimeFormatExtractionFn) SearchHit(io.druid.query.search.search.SearchHit) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 7 with SearchQuery

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

the class SearchQueryRunnerWithCaseTest method testSearchSameValueInMultiDims.

@Test
public void testSearchSameValueInMultiDims() {
    SearchQuery searchQuery;
    Druids.SearchQueryBuilder builder = testBuilder().dimensions(Arrays.asList(placementDimension, placementishDimension));
    Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    searchQuery = builder.query("PREFERRED").build();
    expectedResults.put(placementDimension, Sets.newHashSet("PREFERRED", "preferred", "PREFERRed"));
    expectedResults.put(placementishDimension, Sets.newHashSet("preferred", "Preferred"));
    checkSearchQuery(searchQuery, expectedResults);
    searchQuery = builder.query("preferred", true).build();
    expectedResults.put(placementDimension, Sets.newHashSet("preferred"));
    expectedResults.put(placementishDimension, Sets.newHashSet("preferred"));
    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 8 with SearchQuery

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

the class SearchQueryRunnerWithCaseTest method testFragmentSearch.

@Test
public void testFragmentSearch() {
    Druids.SearchQueryBuilder builder = testBuilder();
    Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    SearchQuery searchQuery;
    searchQuery = builder.fragments(Arrays.asList("auto", "ve")).build();
    expectedResults.put(qualityDimension, Sets.newHashSet("automotive", "AutoMotive"));
    checkSearchQuery(searchQuery, expectedResults);
    searchQuery = builder.fragments(Arrays.asList("auto", "ve"), true).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 9 with SearchQuery

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

the class AppendTest method testFilteredSearch.

@Test
public void testFilteredSearch() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeFilteredSearchQuery();
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : SearchResultValue(io.druid.query.search.SearchResultValue) SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Example 10 with SearchQuery

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

the class SchemalessTestFullTest method testFilteredSearch.

private void testFilteredSearch(QueryRunner runner, List<Result<SearchResultValue>> expectedResults, String failMsg) {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(allGran).filters(marketDimension, "spot").intervals(fullOnInterval).query("a").build();
    failMsg += " filtered search ";
    HashMap<String, Object> context = new HashMap<>();
    Iterable<Result<SearchResultValue>> actualResults = Sequences.toList(runner.run(query, context), Lists.<Result<SearchResultValue>>newArrayList());
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchResultValue(io.druid.query.search.SearchResultValue) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Result(io.druid.query.Result)

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