Search in sources :

Example 21 with SummaryField

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

the class ImplicitSummaries method addToDestination.

private void addToDestination(String destinationName, SummaryField summaryField, Search search) {
    DocumentSummary destination = search.getSummary(destinationName);
    if (destination == null) {
        destination = new DocumentSummary(destinationName);
        search.addSummary(destination);
        destination.add(summaryField);
    } else {
        SummaryField existingField = destination.getSummaryField(summaryField.getName());
        SummaryField merged = summaryField.mergeWith(existingField);
        destination.add(merged);
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 22 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField 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 23 with SummaryField

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

the class SummaryInFieldShortOperation method apply.

public void apply(SDField field) {
    SummaryField ret = field.getSummaryField(name);
    if (ret == null) {
        ret = new SummaryField(name, field.getDataType());
        ret.addSource(field.getName());
        ret.addDestination("default");
    }
    ret.setImplicit(false);
    ret.setTransform(transform);
    for (SummaryField.Source source : sources) {
        ret.addSource(source);
    }
    field.addSummaryField(ret);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 24 with SummaryField

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

the class CreatePositionZCurve method ensureCompatibleSummary.

private void ensureCompatibleSummary(SDField field, String sourceName, String summaryName, DataType summaryType, SummaryTransform summaryTransform, Collection<String> summaryTo, boolean validate) {
    SummaryField summary = search.getSummaryField(summaryName);
    if (summary == null) {
        summary = new SummaryField(summaryName, summaryType, summaryTransform);
        summary.addDestination("default");
        summary.addDestinations(summaryTo);
        field.addSummaryField(summary);
    } else if (!summary.getDataType().equals(summaryType)) {
        if (validate)
            fail(search, field, "Incompatible summary field '" + summaryName + "' type " + summary.getDataType() + " already created.");
    } else if (summary.getTransform() == SummaryTransform.NONE) {
        summary.setTransform(summaryTransform);
        summary.addDestination("default");
        summary.addDestinations(summaryTo);
    } else if (summary.getTransform() != summaryTransform) {
        deployLogger.log(Level.WARNING, "Summary field " + summaryName + " has wrong transform: " + summary.getTransform());
        return;
    }
    SummaryField.Source source = new SummaryField.Source(sourceName);
    summary.getSources().clear();
    summary.addSource(source);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 25 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField 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)

Aggregations

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