use of org.apache.druid.query.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 = new ArrayList<>();
for (String str : TEST_STRINGS) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
use of org.apache.druid.query.search.FragmentSearchQuerySpec in project druid by druid-io.
the class SearchQuerySpecDimExtractionFnTest method testSerde.
@Test
public void testSerde() throws Exception {
ObjectMapper objectMapper = new DefaultObjectMapper();
SearchQuerySpec spec = new FragmentSearchQuerySpec(Arrays.asList("to", "yo"), true);
ExtractionFn extractionFn = new SearchQuerySpecDimExtractionFn(spec);
ExtractionFn extractionFn2 = objectMapper.readValue(objectMapper.writeValueAsBytes(extractionFn), ExtractionFn.class);
FragmentSearchQuerySpec spec2 = (FragmentSearchQuerySpec) ((SearchQuerySpecDimExtractionFn) extractionFn2).getSearchQuerySpec();
Assert.assertEquals(extractionFn, extractionFn2);
Assert.assertEquals(true, spec2.isCaseSensitive());
Assert.assertEquals(ImmutableList.of("to", "yo"), spec2.getValues());
}
use of org.apache.druid.query.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 = new ArrayList<>();
for (String str : TEST_STRINGS) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
use of org.apache.druid.query.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 = new ArrayList<>();
for (String str : TEST_STRINGS) {
String res = extractionFn.apply(str);
if (res != null) {
extracted.add(res);
}
}
Assert.assertEquals(expected, extracted);
}
Aggregations