use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class RankTypeResolver method resolve.
public void resolve() {
RankType rankType = null;
if (fields.size() > 0) {
boolean first = true;
for (SDField field : fields) {
if (first) {
rankType = fields.get(0).getRankType();
first = false;
} else if (!field.getRankType().equals(rankType)) {
deployLogger.log(Level.WARNING, "In field '" + field.getName() + "' " + field.getRankType() + " for index '" + indexName + "' conflicts with " + rankType + " defined for the same index in field '" + field.getName() + "'. Using " + rankType + ".");
field.setRankType(rankType);
}
}
}
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class ArraysTestCase method testArrayImporting.
@Test
public void testArrayImporting() throws IOException, ParseException {
Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/arrays.sd");
SDField tags = (SDField) search.getDocument().getField("tags");
assertEquals(DataType.STRING, ((CollectionDataType) tags.getDataType()).getNestedType());
SDField ratings = (SDField) search.getDocument().getField("ratings");
assertTrue(ratings.getDataType() instanceof ArrayDataType);
assertEquals(DataType.INT, ((ArrayDataType) ratings.getDataType()).getNestedType());
}
use of com.yahoo.searchdefinition.document.SDField 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));
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class AddAttributeTransformToSummaryOfImportedFieldsTest method createSingleImportedField.
private static ImportedFields createSingleImportedField(String fieldName) {
Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
SDField targetField = new SDField("target_field", DataType.INT);
DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class SearchClusterTest method testSdConfigLogical.
@Test
public void testSdConfigLogical() throws IOException, SAXException {
// sd1
SDDocumentType sdt1 = new SDDocumentType("s1");
Search search1 = new Search("s1", null);
SDField f1 = new SDField("f1", DataType.STRING);
f1.addAttribute(new Attribute("f1", DataType.STRING));
f1.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f1"))));
sdt1.addField(f1);
search1.addDocument(sdt1);
// sd2
SDDocumentType sdt2 = new SDDocumentType("s2");
Search search2 = new Search("s2", null);
SDField f2 = new SDField("f2", DataType.STRING);
f2.addAttribute(new Attribute("f2", DataType.STRING));
f2.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f2"))));
sdt2.addField(f2);
search2.addDocument(sdt2);
SearchBuilder builder = new SearchBuilder();
builder.importRawSearch(search1);
builder.importRawSearch(search2);
builder.build();
}
Aggregations