use of io.druid.query.search.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQuerySpecDimExtractionFnTest method testCaseSensitiveExtraction2.
@Test
public void testCaseSensitiveExtraction2() {
SearchQuerySpec spec = new FragmentSearchQuerySpec(Arrays.asList("To", "yo"), true);
ExtractionFn extractionFn = new SearchQuerySpecDimExtractionFn(spec);
List<String> expected = ImmutableList.of("Tokyo", "Toyokawa");
List<String> extracted = Lists.newArrayList();
for (String str : testStrings) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
use of io.druid.query.search.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQueryQueryToolChestTest method testCacheStrategy.
@Test
public void testCacheStrategy() throws Exception {
CacheStrategy<Result<SearchResultValue>, Object, SearchQuery> strategy = new SearchQueryQueryToolChest(null, null).getCacheStrategy(new SearchQuery(new TableDataSource("dummy"), null, Granularities.ALL, 1, new MultipleIntervalSegmentSpec(ImmutableList.of(new Interval("2015-01-01/2015-01-02"))), ImmutableList.of(Druids.DIMENSION_IDENTITY.apply("dim1")), new FragmentSearchQuerySpec(ImmutableList.of("a", "b")), null, null));
final Result<SearchResultValue> result = new Result<>(new DateTime(123L), new SearchResultValue(ImmutableList.of(new SearchHit("dim1", "a"))));
Object preparedValue = strategy.prepareForCache().apply(result);
ObjectMapper objectMapper = new DefaultObjectMapper();
Object fromCacheValue = objectMapper.readValue(objectMapper.writeValueAsBytes(preparedValue), strategy.getCacheObjectClazz());
Result<SearchResultValue> fromCacheResult = strategy.pullFromCache().apply(fromCacheValue);
Assert.assertEquals(result, fromCacheResult);
}
use of io.druid.query.search.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQueryRunnerTest method testFragmentSearch.
@Test
public void testFragmentSearch() {
SearchQuery searchQuery = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).query(new FragmentSearchQuerySpec(Arrays.asList("auto", "ve"))).build();
List<SearchHit> expectedHits = Lists.newLinkedList();
expectedHits.add(new SearchHit(QueryRunnerTestHelper.qualityDimension, "automotive", 93));
checkSearchQuery(searchQuery, expectedHits);
}
use of io.druid.query.search.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQuerySpecDimExtractionFnTest method testCaseSensitiveExtraction.
@Test
public void testCaseSensitiveExtraction() {
SearchQuerySpec spec = new FragmentSearchQuerySpec(Arrays.asList("to", "yo"), true);
ExtractionFn extractionFn = new SearchQuerySpecDimExtractionFn(spec);
List<String> expected = ImmutableList.of("Kyoto");
List<String> extracted = Lists.newArrayList();
for (String str : testStrings) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
use of io.druid.query.search.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQuerySpecDimExtractionFnTest method testExtraction.
@Test
public void testExtraction() {
SearchQuerySpec spec = new FragmentSearchQuerySpec(Arrays.asList("tO", "yO"));
ExtractionFn extractionFn = new SearchQuerySpecDimExtractionFn(spec);
List<String> expected = ImmutableList.of("Kyoto", "Tokyo", "Toyokawa", "Yorktown");
List<String> extracted = Lists.newArrayList();
for (String str : testStrings) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
Aggregations