Search in sources :

Example 1 with DataType

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

the class NewDocumentType method getAllTypes.

public DataTypeCollection getAllTypes() {
    DataTypeRepo repo = new DataTypeRepo();
    Set<Name> seen = new HashSet<>();
    Deque<NewDocumentType> stack = new LinkedList<>();
    stack.push(this);
    while (!stack.isEmpty()) {
        NewDocumentType docType = stack.pop();
        if (seen.contains(docType.name)) {
            // base type
            continue;
        }
        seen.add(docType.name);
        for (DataType dataType : docType.getTypes()) {
            if (repo.getDataType(dataType.getId()) == null) {
                repo.add(dataType);
            }
        }
        stack.addAll(docType.inherits.values());
    }
    return repo;
}
Also used : StructuredDataType(com.yahoo.document.StructuredDataType) DataType(com.yahoo.document.DataType) StructDataType(com.yahoo.document.StructDataType) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with DataType

use of com.yahoo.document.DataType 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 3 with DataType

use of com.yahoo.document.DataType 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 4 with DataType

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

the class TextMatch method process.

@Override
public void process(boolean validate) {
    for (SDField field : search.allConcreteFields()) {
        if (field.getMatching().getType() != Matching.Type.TEXT)
            continue;
        ScriptExpression script = field.getIndexingScript();
        if (script == null)
            continue;
        DataType fieldType = field.getDataType();
        if (fieldType instanceof CollectionDataType) {
            fieldType = ((CollectionDataType) fieldType).getNestedType();
        }
        if (fieldType != DataType.STRING)
            continue;
        Set<String> dynamicSummary = new TreeSet<>();
        Set<String> staticSummary = new TreeSet<>();
        new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, field, dynamicSummary, staticSummary);
        MyVisitor visitor = new MyVisitor(dynamicSummary);
        visitor.visit(script);
        if (!visitor.requiresTokenize)
            continue;
        ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field));
        field.setIndexingScript((ScriptExpression) converter.convert(script));
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TreeSet(java.util.TreeSet) CollectionDataType(com.yahoo.document.CollectionDataType) DataType(com.yahoo.document.DataType) CollectionDataType(com.yahoo.document.CollectionDataType) ExpressionConverter(com.yahoo.vespa.indexinglanguage.ExpressionConverter) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 5 with DataType

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

the class AddExtraFieldsToDocument method addSdField.

private void addSdField(Search search, SDDocumentType document, SDField field, boolean validate) {
    if (field.getIndexToCount() == 0 && field.getAttributes().isEmpty()) {
        return;
    }
    for (Attribute atr : field.getAttributes().values()) {
        if (atr.getName().equals(field.getName() + "_position")) {
            DataType type = PositionDataType.INSTANCE;
            if (atr.getCollectionType().equals(Attribute.CollectionType.ARRAY)) {
                type = DataType.getArray(type);
            }
            addField(search, document, new SDField(document, atr.getName(), type), validate);
        } else if (!atr.getName().equals(field.getName())) {
            addField(search, document, new SDField(document, atr.getName(), atr.getDataType()), validate);
        }
    }
    addField(search, document, field, validate);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) Attribute(com.yahoo.searchdefinition.document.Attribute) PositionDataType(com.yahoo.document.PositionDataType) DataType(com.yahoo.document.DataType)

Aggregations

DataType (com.yahoo.document.DataType)62 ArrayDataType (com.yahoo.document.ArrayDataType)20 MapDataType (com.yahoo.document.MapDataType)19 Field (com.yahoo.document.Field)17 StructDataType (com.yahoo.document.StructDataType)17 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)17 ReferenceDataType (com.yahoo.document.ReferenceDataType)13 PositionDataType (com.yahoo.document.PositionDataType)12 CollectionDataType (com.yahoo.document.CollectionDataType)11 FieldValue (com.yahoo.document.datatypes.FieldValue)11 TensorDataType (com.yahoo.document.TensorDataType)10 DocumentType (com.yahoo.document.DocumentType)9 StructuredDataType (com.yahoo.document.StructuredDataType)7 CollectionFieldValue (com.yahoo.document.datatypes.CollectionFieldValue)6 SDField (com.yahoo.searchdefinition.document.SDField)6 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)5 TemporaryStructuredDataType (com.yahoo.document.TemporaryStructuredDataType)4 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)4 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)4 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)4