Search in sources :

Example 11 with SearchQuery

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

the class SearchQueryRunnerWithCaseTest method testSearch.

@Test
public void testSearch() {
    Druids.SearchQueryBuilder builder = testBuilder();
    Map<String, Set<String>> expectedResults = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    SearchQuery searchQuery;
    searchQuery = builder.query("SPOT").build();
    expectedResults.put(marketDimension, Sets.newHashSet("spot", "SPot"));
    checkSearchQuery(searchQuery, expectedResults);
    searchQuery = builder.query("spot", true).build();
    expectedResults.put(marketDimension, Sets.newHashSet("spot"));
    checkSearchQuery(searchQuery, expectedResults);
    searchQuery = builder.query("SPot", true).build();
    expectedResults.put(marketDimension, Sets.newHashSet("SPot"));
    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 12 with SearchQuery

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

the class AppendTest method testFilteredSearch2.

@Test
public void testFilteredSearch2() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeFilteredSearchQuery();
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment2);
    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 13 with SearchQuery

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

the class AppendTest method testSearchWithOverlap.

@Test
public void testSearchWithOverlap() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeSearchQuery();
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment2);
    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 14 with SearchQuery

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

the class AppendTest method testSearch.

@Test
public void testSearch() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(qualityDimension, "automotive"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeSearchQuery();
    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 15 with SearchQuery

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

the class SchemalessTestFullTest method testFullOnSearch.

private void testFullOnSearch(QueryRunner runner, List<Result<SearchResultValue>> expectedResults, String failMsg) {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(allGran).intervals(fullOnInterval).query("a").build();
    failMsg += " 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