Search in sources :

Example 6 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class FieldOperationApplierForStructs method copyFields.

private void copyFields(SDDocumentType structType, SDDocumentType sdoc) {
    // find all fields in OTHER types that have this type:
    List<SDDocumentType> list = new ArrayList<>();
    list.add(sdoc);
    list.addAll(sdoc.getTypes());
    for (SDDocumentType anyType : list) {
        Iterator<Field> fields = anyType.fieldIterator();
        while (fields.hasNext()) {
            SDField field = (SDField) fields.next();
            DataType structUsedByField = field.getFirstStructRecursive();
            if (structUsedByField == null) {
                continue;
            }
            if (structUsedByField.getName().equals(structType.getName())) {
                // this field is using this type!!
                field.populateWithStructFields(sdoc, field.getName(), field.getDataType(), field.isHeader(), 0);
                field.populateWithStructMatching(sdoc, field.getName(), field.getDataType(), field.getMatching());
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) ArrayList(java.util.ArrayList) DataType(com.yahoo.document.DataType)

Example 7 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SearchDataTypeValidator method validate.

@Override
public void validate(VespaModel model, DeployState deployState) {
    List<AbstractSearchCluster> clusters = model.getSearchClusters();
    for (AbstractSearchCluster cluster : clusters) {
        if (cluster.isStreaming()) {
            continue;
        }
        for (AbstractSearchCluster.SearchDefinitionSpec spec : cluster.getLocalSDS()) {
            SDDocumentType docType = spec.getSearchDefinition().getSearch().getDocument();
            if (docType == null) {
                continue;
            }
            validateDocument(cluster, spec.getSearchDefinition(), docType);
        }
    }
}
Also used : AbstractSearchCluster(com.yahoo.vespa.model.search.AbstractSearchCluster) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType)

Example 8 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SearchDataTypeValidator method validateDocument.

private void validateDocument(AbstractSearchCluster cluster, SearchDefinition def, SDDocumentType doc) {
    for (SDDocumentType child : doc.getTypes()) {
        validateDocument(cluster, def, child);
    }
    for (Field field : doc.fieldSet()) {
        DataType fieldType = field.getDataType();
        disallowIndexingOfMaps(cluster, def, field);
        if (!isSupportedInSearchClusters(fieldType)) {
            throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' is illegal for search " + "clusters (field '" + field.getName() + "' in definition '" + def.getName() + "' for cluster '" + cluster.getClusterName() + "').");
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType)

Example 9 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class DocumentReferenceResolverTest method throws_user_friendly_exception_if_referenced_document_does_not_exist.

@Test
public void throws_user_friendly_exception_if_referenced_document_does_not_exist() {
    // Create foo document with document reference to non-existing document bar
    SDField fooRefToBarField = new SDField("bar_ref", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("bar")));
    addAttributeAspect(fooRefToBarField);
    Search fooSearch = new Search();
    SDDocumentType fooDocument = new SDDocumentType("foo", fooSearch);
    fooDocument.addField(fooRefToBarField);
    fooSearch.addDocument(fooDocument);
    DocumentReferenceResolver resolver = new DocumentReferenceResolver(singletonList(fooSearch));
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("The field 'bar_ref' is an invalid document reference. " + "Could not find document with 'bar' in any search definitions");
    resolver.resolveReferences(fooDocument);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Test(org.junit.Test)

Example 10 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SDDocumentTypeTestCase method testSetGet.

// Verify that we can register and retrieve fields.
@Test
public void testSetGet() {
    SDDocumentType docType = new SDDocumentType("testdoc");
    docType.addField("Bongle", DataType.STRING);
    docType.addField("nalle", DataType.INT);
    assertNotNull(docType.getField("Bongle").getName(), "Bongle");
    assertNull(docType.getField("bongle"));
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Test(org.junit.Test)

Aggregations

SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)48 Test (org.junit.Test)28 SDField (com.yahoo.searchdefinition.document.SDField)23 Search (com.yahoo.searchdefinition.Search)21 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4 ArrayList (java.util.ArrayList)4 DataTypeName (com.yahoo.document.DataTypeName)3 TemporarySDDocumentType (com.yahoo.searchdefinition.document.TemporarySDDocumentType)3 HashMap (java.util.HashMap)3 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 DocumentReferences (com.yahoo.searchdefinition.DocumentReferences)2 RankProfile (com.yahoo.searchdefinition.RankProfile)2 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 DataType (com.yahoo.document.DataType)1