Search in sources :

Example 26 with Search

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());
}
Also used : Search(com.yahoo.searchdefinition.Search) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) Test(org.junit.Test)

Example 27 with Search

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());
}
Also used : Search(com.yahoo.searchdefinition.Search) UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Example 28 with Search

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);
}
Also used : StructDataType(com.yahoo.document.StructDataType) WeightedSetDataType(com.yahoo.document.WeightedSetDataType) Search(com.yahoo.searchdefinition.Search) File(java.io.File) Test(org.junit.Test)

Example 29 with Search

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);
}
Also used : Search(com.yahoo.searchdefinition.Search) File(java.io.File) Test(org.junit.Test)

Example 30 with Search

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;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) DataTypeName(com.yahoo.document.DataTypeName)

Aggregations

Search (com.yahoo.searchdefinition.Search)62 Test (org.junit.Test)47 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)21 SDField (com.yahoo.searchdefinition.document.SDField)15 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)6 File (java.io.File)5 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)4 RankProfile (com.yahoo.searchdefinition.RankProfile)3 Field (com.yahoo.document.Field)2 StructDataType (com.yahoo.document.StructDataType)2 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)2 DocumentReference (com.yahoo.searchdefinition.DocumentReference)2 Index (com.yahoo.searchdefinition.Index)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 ImportedField (com.yahoo.searchdefinition.document.ImportedField)2