Search in sources :

Example 1 with CollectionDataType

use of com.yahoo.document.CollectionDataType 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 2 with CollectionDataType

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

the class TensorFieldProcessor method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    for (SDField field : search.allConcreteFields()) {
        if (field.getDataType() instanceof TensorDataType) {
            validateIndexingScripsForTensorField(field);
            validateAttributeSettingForTensorField(field);
        } else if (field.getDataType() instanceof CollectionDataType) {
            validateDataTypeForCollectionField(field);
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TensorDataType(com.yahoo.document.TensorDataType) CollectionDataType(com.yahoo.document.CollectionDataType)

Example 3 with CollectionDataType

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

the class DocumentModelBuilder method resolveTemporariesRecurse.

@SuppressWarnings("deprecation")
private static DataType resolveTemporariesRecurse(DataType type, DataTypeCollection repo, Collection<NewDocumentType> docs) {
    if (type instanceof TemporaryStructuredDataType) {
        NewDocumentType docType = getDocumentType(docs, type.getId());
        if (docType != null) {
            type = docType;
            return type;
        }
        DataType real = repo.getDataType(type.getId());
        if (real == null) {
            throw new NullPointerException("Can not find type '" + type.toString() + "', impossible.");
        }
        type = real;
    } else if (type instanceof StructDataType) {
        StructDataType dt = (StructDataType) type;
        for (com.yahoo.document.Field field : dt.getFields()) {
            if (field.getDataType() != type) {
                // XXX deprecated:
                field.setDataType(resolveTemporariesRecurse(field.getDataType(), repo, docs));
            }
        }
    } else if (type instanceof MapDataType) {
        MapDataType t = (MapDataType) type;
        t.setKeyType(resolveTemporariesRecurse(t.getKeyType(), repo, docs));
        t.setValueType(resolveTemporariesRecurse(t.getValueType(), repo, docs));
    } else if (type instanceof CollectionDataType) {
        CollectionDataType t = (CollectionDataType) type;
        t.setNestedType(resolveTemporariesRecurse(t.getNestedType(), repo, docs));
    } else if (type instanceof ReferenceDataType) {
        ReferenceDataType t = (ReferenceDataType) type;
        if (t.getTargetType() instanceof TemporaryStructuredDataType) {
            DataType targetType = resolveTemporariesRecurse(t.getTargetType(), repo, docs);
            t.setTargetType((StructuredDataType) targetType);
        }
    }
    return type;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field) TemporaryStructuredDataType(com.yahoo.document.TemporaryStructuredDataType) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType) StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) 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) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) MapDataType(com.yahoo.document.MapDataType)

Example 4 with CollectionDataType

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

the class DocumentModelBuilder method extractNestedTypes.

private static void extractNestedTypes(NewDocumentType dt, DataType type) {
    if (type instanceof StructDataType) {
        StructDataType tmp = (StructDataType) type;
        extractDataTypesFromFields(dt, tmp.getFieldsThisTypeOnly());
    } else if (type instanceof DocumentType) {
        throw new IllegalArgumentException("Can not handle nested document definitions. In document type '" + dt.getName().toString() + "', we can not define document type '" + type.toString());
    } else if (type instanceof CollectionDataType) {
        CollectionDataType tmp = (CollectionDataType) type;
        extractNestedTypes(dt, tmp.getNestedType());
        addType(dt, tmp.getNestedType());
    } else if (type instanceof MapDataType) {
        MapDataType tmp = (MapDataType) type;
        extractNestedTypes(dt, tmp.getKeyType());
        extractNestedTypes(dt, tmp.getValueType());
        addType(dt, tmp.getKeyType());
        addType(dt, tmp.getValueType());
    } else if (type instanceof TemporaryAnnotationReferenceDataType) {
        throw new IllegalArgumentException(type.toString());
    }
}
Also used : StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) VespaDocumentType(com.yahoo.documentmodel.VespaDocumentType) MapDataType(com.yahoo.document.MapDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)

Example 5 with CollectionDataType

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

the class DocumentModelBuilder method specialHandleAnnotationReferenceRecurse.

private static DataType specialHandleAnnotationReferenceRecurse(NewDocumentType docType, String fieldName, DataType dataType) {
    if (dataType instanceof TemporaryAnnotationReferenceDataType) {
        TemporaryAnnotationReferenceDataType refType = (TemporaryAnnotationReferenceDataType) dataType;
        if (refType.getId() != 0) {
            return null;
        }
        AnnotationType target = docType.getAnnotationType(refType.getTarget());
        if (target == null) {
            throw new RetryLaterException("Annotation '" + refType.getTarget() + "' in reference '" + fieldName + "' does not exist.");
        }
        dataType = new AnnotationReferenceDataType(target);
        addType(docType, dataType);
        return dataType;
    } else if (dataType instanceof MapDataType) {
        MapDataType mapType = (MapDataType) dataType;
        DataType valueType = specialHandleAnnotationReferenceRecurse(docType, fieldName, mapType.getValueType());
        if (valueType == null) {
            return null;
        }
        mapType = mapType.clone();
        mapType.setValueType(valueType);
        addType(docType, mapType);
        return mapType;
    } else if (dataType instanceof CollectionDataType) {
        CollectionDataType lstType = (CollectionDataType) dataType;
        DataType nestedType = specialHandleAnnotationReferenceRecurse(docType, fieldName, lstType.getNestedType());
        if (nestedType == null) {
            return null;
        }
        lstType = lstType.clone();
        lstType.setNestedType(nestedType);
        addType(docType, lstType);
        return lstType;
    }
    return null;
}
Also used : AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) CollectionDataType(com.yahoo.document.CollectionDataType) 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) MapDataType(com.yahoo.document.MapDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) SDAnnotationType(com.yahoo.searchdefinition.document.annotation.SDAnnotationType) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Aggregations

CollectionDataType (com.yahoo.document.CollectionDataType)7 DataType (com.yahoo.document.DataType)3 MapDataType (com.yahoo.document.MapDataType)3 StructDataType (com.yahoo.document.StructDataType)3 SDField (com.yahoo.searchdefinition.document.SDField)3 TemporaryAnnotationReferenceDataType (com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)3 Field (com.yahoo.document.Field)2 ReferenceDataType (com.yahoo.document.ReferenceDataType)2 StructuredDataType (com.yahoo.document.StructuredDataType)2 TemporaryStructuredDataType (com.yahoo.document.TemporaryStructuredDataType)2 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)2 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 ArrayDataType (com.yahoo.document.ArrayDataType)1 DocumentType (com.yahoo.document.DocumentType)1 TensorDataType (com.yahoo.document.TensorDataType)1 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)1 AnnotationType (com.yahoo.document.annotation.AnnotationType)1 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)1 CollectionFieldValue (com.yahoo.document.datatypes.CollectionFieldValue)1 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)1