use of com.yahoo.vespa.model.search.SearchDefinition in project vespa by vespa-engine.
the class ClusterTest method newSearchDefinition.
private static SearchDefinition newSearchDefinition(String name) throws ParseException {
SearchBuilder builder = new SearchBuilder();
builder.importString("search " + name + " { document " + name + " { } }");
builder.build();
return new SearchDefinition(name, builder.getSearch(name));
}
use of com.yahoo.vespa.model.search.SearchDefinition in project vespa by vespa-engine.
the class RankingConstantsValidator method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
ApplicationPackage applicationPackage = deployState.getApplicationPackage();
ExceptionMessageCollector exceptionMessageCollector = new ExceptionMessageCollector("Invalid constant tensor file(s):");
for (SearchDefinition sd : deployState.getSearchDefinitions()) {
for (RankingConstant rc : sd.getSearch().getRankingConstants().values()) {
try {
validateRankingConstant(rc, applicationPackage);
} catch (InvalidConstantTensor | FileNotFoundException ex) {
exceptionMessageCollector.add(ex, rc.getName(), rc.getFileName());
}
}
}
if (exceptionMessageCollector.exceptionsOccurred) {
throw new TensorValidationFailed(exceptionMessageCollector.combinedMessage);
}
}
use of com.yahoo.vespa.model.search.SearchDefinition in project vespa by vespa-engine.
the class ApplicationDeployTest method testVespaModel.
@Test
public void testVespaModel() throws SAXException, IOException {
FilesApplicationPackage app = createAppPkg(TESTDIR + "app1");
assertThat(app.getApplicationName(), is("app1"));
VespaModel model = new VespaModel(app);
List<SearchDefinition> searchDefinitions = getSearchDefinitions(app);
assertEquals(searchDefinitions.size(), 5);
for (SearchDefinition searchDefinition : searchDefinitions) {
Search s = searchDefinition.getSearch();
switch(s.getName()) {
case "music":
case "laptop":
case "pc":
case "sock":
break;
case "product":
assertTrue(s instanceof UnproperSearch);
assertEquals(s.getDocument().getField("title").getDataType(), DataType.STRING);
break;
default:
fail();
}
}
File[] truth = new File[] { new File(TESTSDDIR + "laptop.sd"), new File(TESTSDDIR + "music.sd"), new File(TESTSDDIR + "pc.sd"), new File(TESTSDDIR + "product.sd"), new File(TESTSDDIR + "sock.sd") };
Arrays.sort(truth);
List<File> appSdFiles = app.getSearchDefinitionFiles();
Collections.sort(appSdFiles);
assertEquals(appSdFiles, Arrays.asList(truth));
List<FilesApplicationPackage.Component> components = app.getComponents();
assertEquals(1, components.size());
Map<String, Bundle.DefEntry> defEntriesByName = defEntries2map(components.get(0).getDefEntries());
assertEquals(5, defEntriesByName.size());
Bundle.DefEntry def1 = defEntriesByName.get("test-namespace");
assertNotNull(def1);
assertEquals("namespace=config\nintVal int default=0", def1.contents);
Bundle.DefEntry def2 = defEntriesByName.get("namespace-in-filename");
assertNotNull(def2);
assertEquals("namespace=a.b\n\ndoubleVal double default=0.0", def2.contents);
// Check that getFilename works
ArrayList<String> sdFileNames = new ArrayList<>();
for (SearchDefinition sd : searchDefinitions) {
sdFileNames.add(sd.getFilename());
}
Collections.sort(sdFileNames);
assertThat(sdFileNames.get(0), is("laptop.sd"));
assertThat(sdFileNames.get(1), is("music.sd"));
assertThat(sdFileNames.get(2), is("pc.sd"));
assertThat(sdFileNames.get(3), is("product.sd"));
assertThat(sdFileNames.get(4), is("sock.sd"));
}
Aggregations