Search in sources :

Example 6 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class ContentCluster method getConfig.

@Override
public void getConfig(BucketspacesConfig.Builder builder) {
    for (NewDocumentType docType : getDocumentDefinitions().values()) {
        BucketspacesConfig.Documenttype.Builder docTypeBuilder = new BucketspacesConfig.Documenttype.Builder();
        docTypeBuilder.name(docType.getName());
        String bucketSpace = ((enableMultipleBucketSpaces && isGloballyDistributed(docType)) ? GLOBAL_BUCKET_SPACE : DEFAULT_BUCKET_SPACE);
        docTypeBuilder.bucketspace(bucketSpace);
        builder.documenttype(docTypeBuilder);
    }
    builder.enable_multiple_bucket_spaces(enableMultipleBucketSpaces);
}
Also used : BucketspacesConfig(com.yahoo.vespa.config.content.core.BucketspacesConfig) ContainerModelBuilder(com.yahoo.vespa.model.container.xml.ContainerModelBuilder) NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 7 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class SearchDefinitionBuilder method build.

public Map<String, NewDocumentType> build(DocumentTypeRepo repo, ModelElement elem) {
    Map<String, NewDocumentType> docTypes = new TreeMap<>();
    if (elem != null) {
        for (ModelElement e : elem.subElements("document")) {
            // Schema-guaranteed presence
            String name = e.getStringAttribute("type");
            NewDocumentType documentType = repo.getDocumentType(name);
            if (documentType != null) {
                docTypes.put(documentType.getName(), documentType);
            } else {
                throw new RuntimeException("Document type '" + name + "' not found in application package");
            }
        }
    }
    return docTypes;
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) TreeMap(java.util.TreeMap)

Example 8 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentTypeChangeValidatorTest method createDocumentTypeWithReferenceField.

private static NewDocumentType createDocumentTypeWithReferenceField(String nameReferencedDocumentType) {
    StructDataType headerfields = new StructDataType("headerfields");
    headerfields.addField(new Field("ref", new ReferenceDataType(new DocumentType(nameReferencedDocumentType), 0)));
    return new NewDocumentType(new NewDocumentType.Name("mydoc"), headerfields, new StructDataType("bodyfields"), new FieldSets(), Collections.emptySet());
}
Also used : Field(com.yahoo.document.Field) FieldSets(com.yahoo.searchdefinition.FieldSets) ReferenceDataType(com.yahoo.document.ReferenceDataType) StructDataType(com.yahoo.document.StructDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType)

Example 9 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentModelBuilderReferenceTypeTestCase method reference_data_type_has_a_concrete_target_type.

@Test
public void reference_data_type_has_a_concrete_target_type() throws ParseException {
    DocumentModel model = new TestDocumentModelBuilder().addCampaign().build(joinLines("search ad {", "  document ad {", "    field campaign_ref type reference<campaign> { indexing: attribute }", "  }", "}"));
    NewDocumentType campaignType = model.getDocumentManager().getDocumentType("campaign");
    NewDocumentType adType = model.getDocumentManager().getDocumentType("ad");
    ReferenceDataType campaignRefType = (ReferenceDataType) adType.getField("campaign_ref").getDataType();
    assertEquals(campaignRefType.getTargetType(), campaignType);
}
Also used : ReferenceDataType(com.yahoo.document.ReferenceDataType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 10 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class GlobalDistributionValidatorTest method validation_succeeds_if_referenced_document_is_global.

@Test
public void validation_succeeds_if_referenced_document_is_global() {
    NewDocumentType parent = createDocumentType("parent");
    Fixture fixture = new Fixture().addGlobalDocument(parent).addNonGlobalDocument(createDocumentType("child", parent));
    Redundancy redundancy = createRedundancyWithGlobalDistribution();
    validate(fixture, redundancy);
}
Also used : NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Aggregations

NewDocumentType (com.yahoo.documentmodel.NewDocumentType)23 Test (org.junit.Test)7 StructDataType (com.yahoo.document.StructDataType)4 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)4 ReferenceDataType (com.yahoo.document.ReferenceDataType)3 AnnotationType (com.yahoo.document.annotation.AnnotationType)3 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)3 MockRoot (com.yahoo.config.model.test.MockRoot)2 CollectionDataType (com.yahoo.document.CollectionDataType)2 DocumentType (com.yahoo.document.DocumentType)2 Field (com.yahoo.document.Field)2 MapDataType (com.yahoo.document.MapDataType)2 VespaDocumentType (com.yahoo.documentmodel.VespaDocumentType)2 TemporaryAnnotationReferenceDataType (com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)2 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)2 HashSet (java.util.HashSet)2 DeployState (com.yahoo.config.model.deploy.DeployState)1 com.yahoo.document (com.yahoo.document)1 DataType (com.yahoo.document.DataType)1 StructuredDataType (com.yahoo.document.StructuredDataType)1