use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class ImplicitSummaryFieldsTestCase method testRequireThatImplicitFieldsAreCreated.
@Test
public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd");
assertNotNull(search);
DocumentSummary docsum = search.getSummary("default");
assertNotNull(docsum);
assertNotNull(docsum.getSummaryField("rankfeatures"));
assertNotNull(docsum.getSummaryField("summaryfeatures"));
assertEquals(2, docsum.getSummaryFields().size());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class DocumentGenMojo method execute.
void execute(File sdDir, File outputDir, String packageName) throws MojoFailureException {
if ("".equals(packageName))
throw new IllegalArgumentException("You may not use empty package for generated types.");
searches = new HashMap<String, Search>();
docTypes = new HashMap<String, String>();
structTypes = new HashMap<String, String>();
annotationTypes = new HashMap<String, String>();
outputDir.mkdirs();
SearchBuilder builder = buildSearches(sdDir);
boolean annotationsExported = false;
for (NewDocumentType docType : builder.getModel().getDocumentManager().getTypes()) {
if (docType != VespaDocumentType.INSTANCE) {
exportDocumentSources(outputDir, docType, packageName);
for (AnnotationType annotationType : docType.getAllAnnotations()) {
if (provided(annotationType.getName()) != null)
continue;
annotationsExported = true;
exportAnnotationSources(outputDir, annotationType, docType, packageName);
}
}
}
exportPackageInfo(outputDir, packageName);
if (annotationsExported)
exportPackageInfo(outputDir, packageName + ".annotation");
exportDocFactory(outputDir, builder.getSearchList(), packageName);
if (project != null)
project.addCompileSourceRoot(outputDirectory.toString());
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class DocumentGenTest method testLocalApp.
@Test
public void testLocalApp() throws MojoFailureException {
DocumentGenMojo mojo = new DocumentGenMojo();
mojo.execute(new File("etc/localapp/"), new File("target/generated-test-sources/vespa-documentgen-plugin/"), "com.yahoo.vespa.document");
Map<String, Search> searches = mojo.getSearches();
assertEquals(searches.get("video").getDocument("video").getField("weight").getDataType(), DataType.FLOAT);
assertTrue(searches.get("book").getDocument("book").getField("mystruct").getDataType() instanceof StructDataType);
assertTrue(searches.get("book").getDocument("book").getField("mywsfloat").getDataType() instanceof WeightedSetDataType);
assertTrue(((WeightedSetDataType) (searches.get("book").getDocument("book").getField("mywsfloat").getDataType())).getNestedType() == DataType.FLOAT);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class DocumentGenTest method testMusic.
@Test
public void testMusic() throws MojoExecutionException, MojoFailureException {
DocumentGenMojo mojo = new DocumentGenMojo();
mojo.execute(new File("etc/music/"), new File("target/generated-test-sources/vespa-documentgen-plugin/"), "com.yahoo.vespa.document");
Map<String, Search> searches = mojo.getSearches();
assertEquals(searches.size(), 1);
assertEquals(searches.get("music").getDocument("music").getField("title").getDataType(), DataType.STRING);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SearchOrderer method allInheritedDependenciesEmitted.
private boolean allInheritedDependenciesEmitted(List<Search> alreadyOrdered, SDDocumentType document) {
for (SDDocumentType sdoc : document.getInheritedTypes()) {
DataTypeName inheritedName = sdoc.getDocumentName();
if ("document".equals(inheritedName.getName())) {
continue;
}
Search inheritedSearch = documentNameToSearch.get(inheritedName);
if (!alreadyOrdered.contains(inheritedSearch)) {
return false;
}
}
return true;
}
Aggregations