use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImplicitSearchFieldsTestCase method testRequireThatSummaryFieldsAreIncluded.
@Test
public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd");
assertNotNull(search);
SDDocumentType docType = search.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("rankfeatures"));
assertNotNull(docType.getField("summaryfeatures"));
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
assertNotNull(docType.getField("cox"));
assertEquals(5, docType.getFieldCount());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImplicitSearchFieldsTestCase method testRequireThatBoldedSummaryFieldsAreIncluded.
@Test
public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd");
assertNotNull(search);
SDDocumentType docType = search.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("rankfeatures"));
assertNotNull(docType.getField("summaryfeatures"));
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
assertNotNull(docType.getField("baz"));
assertNotNull(docType.getField("cox"));
assertEquals(6, docType.getFieldCount());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImplicitSummariesTestCase method requireThatSummaryFromAttributeDoesNotWarn.
@Test
public void requireThatSummaryFromAttributeDoesNotWarn() throws IOException, ParseException {
LogHandler log = new LogHandler();
Logger.getLogger("").addHandler(log);
Search search = SearchBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd");
assertNotNull(search);
assertTrue(log.records.isEmpty());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class NGramTestCase method testInvalidNGramSetting3.
@Test
public void testInvalidNGramSetting3() throws IOException, ParseException {
try {
Search search = SearchBuilder.buildFromFile("src/test/examples/invalidngram3.sd");
fail("Should cause an exception");
} catch (IllegalArgumentException e) {
assertEquals("gram matching is not supported with attributes, use 'index' not 'attribute' in indexing", e.getMessage());
}
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class NGramTestCase method testNGram.
@Test
public void testNGram() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/ngram.sd");
assertNotNull(search);
SDField gram1 = search.getConcreteField("gram_1");
assertEquals(Matching.Type.GRAM, gram1.getMatching().getType());
assertEquals(1, gram1.getMatching().getGramSize());
SDField gram2 = search.getConcreteField("gram_2");
assertEquals(Matching.Type.GRAM, gram2.getMatching().getType());
// Not set explicitly
assertEquals(-1, gram2.getMatching().getGramSize());
SDField gram3 = search.getConcreteField("gram_3");
assertEquals(Matching.Type.GRAM, gram3.getMatching().getType());
assertEquals(3, gram3.getMatching().getGramSize());
assertEquals("input gram_1 | ngram 1 | index gram_1 | summary gram_1", gram1.getIndexingScript().iterator().next().toString());
assertEquals("input gram_2 | ngram 2 | index gram_2", gram2.getIndexingScript().iterator().next().toString());
assertEquals("input gram_3 | ngram 3 | index gram_3", gram3.getIndexingScript().iterator().next().toString());
assertFalse(gram1.getNormalizing().doRemoveAccents());
assertEquals(Stemming.NONE, gram1.getStemming());
List<String> queryCommands = gram1.getQueryCommands();
assertEquals(1, queryCommands.size());
assertEquals("ngram 1", queryCommands.get(0));
}
Aggregations