use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class RankPropertyVariablesTestCase method testRankPropVariables.
@Test
public void testRankPropVariables() throws IOException, ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd", new BaseDeployLogger(), rankProfileRegistry, new QueryProfileRegistry());
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar1", "foo");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar_2", "bar");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvarOne23", "baz");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar1", "1");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar_4", "4");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$testvarFour23", "234234.234");
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ValidateFieldTypesTest method createSearchWithDocument.
private static Search createSearchWithDocument(String documentName) {
Search search = new Search(documentName, MockApplicationPackage.createEmpty());
SDDocumentType document = new SDDocumentType(documentName, search);
search.addDocument(document);
return search;
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ValidateFieldTypesTest method throws_exception_if_type_of_document_field_does_not_match_summary_field.
@Test
public void throws_exception_if_type_of_document_field_does_not_match_summary_field() {
Search search = createSearchWithDocument(DOCUMENT_NAME);
search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT));
search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING));
ValidateFieldTypes validator = new ValidateFieldTypes(search, null, null, null);
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("For search '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " + "Expected int for summary field '" + IMPORTED_FIELD_NAME + "', got string.");
validator.process(true);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SimpleInheritTestCase method testEmptyChild.
@Test
public void testEmptyChild() throws IOException, ParseException {
String name = "emptychild";
final String expectedResultsDirName = "src/test/derived/" + name + "/";
SearchBuilder builder = new SearchBuilder();
builder.importFile(expectedResultsDirName + "parent.sd");
builder.importFile(expectedResultsDirName + "child.sd");
builder.build();
Search search = builder.getSearch("child");
String toDirName = "temp/" + name;
File toDir = new File(toDirName);
toDir.mkdirs();
deleteContent(toDir);
DerivedConfiguration config = new DerivedConfiguration(search, builder.getRankProfileRegistry(), new QueryProfileRegistry());
config.export(toDirName);
checkDir(toDirName, expectedResultsDirName);
}
use of com.yahoo.searchdefinition.Search 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));
}
Aggregations