Search in sources :

Example 1 with Field

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

the class DocumentModelBuilder method extractDataTypesFromFields.

private static void extractDataTypesFromFields(NewDocumentType dt, Collection<Field> fields) {
    for (Field f : fields) {
        DataType type = f.getDataType();
        if (testAddType(dt, type)) {
            extractNestedTypes(dt, type);
            addType(dt, type);
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field) StructuredDataType(com.yahoo.document.StructuredDataType) TemporaryStructuredDataType(com.yahoo.document.TemporaryStructuredDataType) DataType(com.yahoo.document.DataType) StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) MapDataType(com.yahoo.document.MapDataType) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType)

Example 2 with Field

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

the class DocumentModelBuilder method handleStruct.

private static StructDataType handleStruct(NewDocumentType dt, StructDataType s) {
    for (Field f : s.getFieldsThisTypeOnly()) {
        specialHandleAnnotationReference(dt, f);
    }
    extractNestedTypes(dt, s);
    addType(dt, s);
    return s;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field)

Example 3 with Field

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

the class DocumentModelBuilder method addToModel.

public void addToModel(Search search) {
    // Then we add the search specific stuff
    SearchDef searchDef = new SearchDef(search.getName());
    addSearchFields(search.extraFieldList(), searchDef);
    for (Field f : search.getDocument().fieldSet()) {
        addSearchField((SDField) f, searchDef);
    }
    for (SDField field : search.allConcreteFields()) {
        for (Attribute attribute : field.getAttributes().values()) {
            if (!searchDef.getFields().containsKey(attribute.getName())) {
                searchDef.add(new SearchField(new Field(attribute.getName(), field), !field.getIndices().isEmpty(), true));
            }
        }
    }
    for (Field f : search.getDocument().fieldSet()) {
        addAlias((SDField) f, searchDef);
    }
    model.getSearchManager().add(searchDef);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field) SearchDef(com.yahoo.vespa.documentmodel.SearchDef) SearchField(com.yahoo.vespa.documentmodel.SearchField) SDField(com.yahoo.searchdefinition.document.SDField) Attribute(com.yahoo.searchdefinition.document.Attribute)

Example 4 with Field

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

the class IndexSchema method deriveIndexFields.

private void deriveIndexFields(ImmutableSDField field, Search search) {
    if (!field.doesIndexing() && !field.isIndexStructureField()) {
        return;
    }
    List<Field> lst = flattenField(field.asField());
    if (lst.isEmpty()) {
        return;
    }
    String fieldName = field.getName();
    for (Field flatField : lst) {
        deriveIndexFields(flatField, search);
    }
    if (lst.size() > 1) {
        FieldSet fieldSet = new FieldSet(fieldName);
        for (Field flatField : lst) {
            fieldSet.addFieldName(flatField.getName());
        }
        fieldSets.put(fieldName, fieldSet);
    }
}
Also used : Field(com.yahoo.document.Field) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) FieldSet(com.yahoo.searchdefinition.document.FieldSet)

Example 5 with Field

use of com.yahoo.document.Field 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)

Aggregations

Field (com.yahoo.document.Field)115 Test (org.junit.Test)50 StructDataType (com.yahoo.document.StructDataType)46 DocumentType (com.yahoo.document.DocumentType)24 DataType (com.yahoo.document.DataType)17 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)14 ReferenceDataType (com.yahoo.document.ReferenceDataType)13 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)13 ArrayDataType (com.yahoo.document.ArrayDataType)12 MapDataType (com.yahoo.document.MapDataType)12 TensorDataType (com.yahoo.document.TensorDataType)11 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)11 SDField (com.yahoo.searchdefinition.document.SDField)10 PositionDataType (com.yahoo.document.PositionDataType)9 FieldValue (com.yahoo.document.datatypes.FieldValue)9 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)9 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)8 Struct (com.yahoo.document.datatypes.Struct)7 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)6 Document (com.yahoo.document.Document)5