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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations