Search in sources :

Example 11 with DocumentSummary

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

the class ImplicitSummaries method collectSummaries.

private void collectSummaries(SDField field, Search search, boolean validate) {
    SummaryField addedSummaryField = null;
    // Implicit
    String fieldName = field.getName();
    SummaryField fieldSummaryField = field.getSummaryField(fieldName);
    if (fieldSummaryField == null && field.doesSummarying()) {
        fieldSummaryField = new SummaryField(fieldName, field.getDataType());
        fieldSummaryField.setImplicit(true);
        addSummaryFieldSources(fieldSummaryField, field);
        fieldSummaryField.addDestination("default");
        field.addSummaryField(fieldSummaryField);
        addedSummaryField = fieldSummaryField;
    }
    if (fieldSummaryField != null) {
        for (String dest : fieldSummaryField.getDestinations()) {
            DocumentSummary summary = search.getSummary(dest);
            if (summary != null) {
                summary.add(fieldSummaryField);
            }
        }
    }
    // Attribute prefetch
    for (Attribute attribute : field.getAttributes().values()) {
        if (attribute.getName().equals(fieldName)) {
            if (addedSummaryField != null) {
                addedSummaryField.setTransform(SummaryTransform.ATTRIBUTE);
            }
            if (attribute.isPrefetch()) {
                addPrefetchAttribute(attribute, field, search);
            }
        }
    }
    // Position attributes
    if (field.doesSummarying()) {
        for (Attribute attribute : field.getAttributes().values()) {
            if (!attribute.isPosition())
                continue;
            DocumentSummary attributePrefetchSummary = getOrCreateAttributePrefetchSummary(search);
            attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getDistanceSummaryFieldName(fieldName)));
            attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getPositionSummaryFieldName(fieldName)));
        }
    }
    // Explicits
    for (SummaryField summaryField : field.getSummaryFields()) {
        // Make sure we fetch from attribute here too
        Attribute attribute = field.getAttributes().get(fieldName);
        if (attribute != null && summaryField.getTransform() == SummaryTransform.NONE) {
            summaryField.setTransform(SummaryTransform.ATTRIBUTE);
        }
        if (isValid(summaryField, search, validate)) {
            addToDestinations(summaryField, search);
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Attribute(com.yahoo.searchdefinition.document.Attribute) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 12 with DocumentSummary

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

the class SummaryConsistency method process.

@Override
public void process(boolean validate) {
    for (DocumentSummary summary : search.getSummaries().values()) {
        if (summary.getName().equals("default"))
            continue;
        for (SummaryField summaryField : summary.getSummaryFields()) {
            assertConsistency(summaryField, search, validate);
            makeAttributeTransformIfAppropriate(summaryField, search);
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 13 with DocumentSummary

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

the class ValidateFieldTypes method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    String searchName = search.getName();
    Map<String, DataType> seenFields = new HashMap<>();
    search.allFields().forEach(field -> {
        checkFieldType(searchName, "index field", field.getName(), field.getDataType(), seenFields);
        for (Map.Entry<String, Attribute> entry : field.getAttributes().entrySet()) {
            checkFieldType(searchName, "attribute", entry.getKey(), entry.getValue().getDataType(), seenFields);
        }
    });
    for (DocumentSummary summary : search.getSummaries().values()) {
        for (SummaryField field : summary.getSummaryFields()) {
            checkFieldType(searchName, "summary field", field.getName(), field.getDataType(), seenFields);
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) HashMap(java.util.HashMap) Attribute(com.yahoo.searchdefinition.document.Attribute) TensorDataType(com.yahoo.document.TensorDataType) DataType(com.yahoo.document.DataType) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)13 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)10 Attribute (com.yahoo.searchdefinition.document.Attribute)3 SDField (com.yahoo.searchdefinition.document.SDField)2 HashMap (java.util.HashMap)2 Pair (com.yahoo.collections.Pair)1 DataType (com.yahoo.document.DataType)1 TensorDataType (com.yahoo.document.TensorDataType)1 Index (com.yahoo.searchdefinition.Index)1 Search (com.yahoo.searchdefinition.Search)1 BooleanIndexDefinition (com.yahoo.searchdefinition.document.BooleanIndexDefinition)1 Source (com.yahoo.vespa.documentmodel.SummaryField.Source)1 Map (java.util.Map)1 Test (org.junit.Test)1