use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SummaryTestCase method testDeriving.
@Test
public void testDeriving() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/simple.sd");
SummaryClass summary = new SummaryClass(search, search.getSummary("default"), new BaseDeployLogger());
assertEquals("default", summary.getName());
Iterator<SummaryClassField> fields = summary.fieldIterator();
SummaryClassField field;
assertEquals(13, summary.getFieldCount());
field = (SummaryClassField) fields.next();
assertEquals("exactemento", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("exact", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("title", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("description", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("dyndesc", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("longdesc", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("longstat", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("dynlong", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("dyndesc2", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("measurement", field.getName());
assertEquals(SummaryClassField.Type.INTEGER, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("rankfeatures", field.getName());
assertEquals(SummaryClassField.Type.FEATUREDATA, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("summaryfeatures", field.getName());
assertEquals(SummaryClassField.Type.FEATUREDATA, field.getType());
field = (SummaryClassField) fields.next();
assertEquals("documentid", field.getName());
assertEquals(SummaryClassField.Type.LONGSTRING, field.getType());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class TypeConversionTestCase method testExactStringToStringTypeConversion.
/**
* Tests that exact-string stuff is not spilled over to the default index
*/
@Test
public void testExactStringToStringTypeConversion() {
Search search = new Search("test", null);
RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
SDDocumentType document = new SDDocumentType("test");
search.addDocument(document);
SDField a = new SDField("a", DataType.STRING);
a.parseIndexingScript("{ index }");
document.addField(a);
Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
IndexInfo indexInfo = derived.getIndexInfo();
assertFalse(indexInfo.hasCommand("default", "compact-to-term"));
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImportedFieldsResolver method validateTargetField.
private SDField validateTargetField(TemporaryImportedField importedField, DocumentReference reference, boolean validate) {
String targetFieldName = importedField.targetFieldName();
Search targetSearch = reference.targetSearch();
if (validate && isImportedField(targetSearch, targetFieldName)) {
fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is an imported field. Not supported");
}
SDField targetField = targetSearch.getConcreteField(targetFieldName);
if (targetField == null) {
fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Not found");
} else if (!targetField.doesAttributing()) {
if (validate)
fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is not an attribute field. Only attribute fields supported");
} else if (targetField.doesIndexing()) {
if (validate)
fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is an index field. Not supported");
}
return targetField;
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class NoPrefixForIndexes method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
for (AbstractSearchCluster cluster : model.getSearchClusters()) {
if (cluster instanceof IndexedSearchCluster) {
IndexedSearchCluster sc = (IndexedSearchCluster) cluster;
for (DocumentDatabase docDb : sc.getDocumentDbs()) {
DerivedConfiguration sdConfig = docDb.getDerivedConfiguration();
Search search = sdConfig.getSearch();
for (SDField field : search.allConcreteFields()) {
if (field.doesIndexing()) {
// if (!field.getIndexTo().isEmpty() && !field.getIndexTo().contains(field.getName())) continue;
if (field.getMatching().getAlgorithm().equals(Matching.Algorithm.PREFIX)) {
failField(search, field);
}
for (Map.Entry<String, Index> e : field.getIndices().entrySet()) {
if (e.getValue().isPrefix()) {
failField(search, field);
}
}
}
}
}
}
}
}
use of com.yahoo.searchdefinition.Search 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