Search in sources :

Example 6 with SummaryField

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

the class CreatePositionZCurve method removeSummaryTo.

private Set<String> removeSummaryTo(SDField field) {
    Set<String> summaryTo = new HashSet<>();
    Collection<SummaryField> summaryFields = field.getSummaryFields();
    for (SummaryField summary : summaryFields) {
        summaryTo.addAll(summary.getDestinations());
    }
    summaryFields.clear();
    return summaryTo;
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) HashSet(java.util.HashSet)

Example 7 with SummaryField

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

the class ImplicitSummaries method addPrefetchAttribute.

private void addPrefetchAttribute(Attribute attribute, SDField field, Search search) {
    if (attribute.getPrefetchValue() == null) {
        // Prefetch by default - unless any summary makes this dynamic
        // Check if there is an implicit dynamic definition
        SummaryField fieldSummaryField = field.getSummaryField(attribute.getName());
        if (fieldSummaryField != null && fieldSummaryField.getTransform().isDynamic())
            return;
        // Check if an explicit class makes it dynamic (first is enough, as all must be the same, checked later)
        SummaryField explicitSummaryField = search.getExplicitSummaryField(attribute.getName());
        if (explicitSummaryField != null && explicitSummaryField.getTransform().isDynamic())
            return;
    }
    DocumentSummary summary = getOrCreateAttributePrefetchSummary(search);
    SummaryField attributeSummaryField = new SummaryField(attribute.getName(), attribute.getDataType());
    attributeSummaryField.addSource(attribute.getName());
    attributeSummaryField.addDestination("attributeprefetch");
    attributeSummaryField.setTransform(SummaryTransform.ATTRIBUTE);
    summary.add(attributeSummaryField);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 8 with SummaryField

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

the class SummaryInFieldLongOperation method apply.

public void apply(SDField field) {
    if (type == null) {
        type = field.getDataType();
    }
    SummaryField summary = new SummaryField(name, type);
    applyToSummary(summary);
    field.addSummaryField(summary);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 9 with SummaryField

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

the class BoldingOperation method apply.

public void apply(SDField field) {
    SummaryField summaryField = field.getSummaryField(field.getName(), true);
    summaryField.addSource(field.getName());
    summaryField.addDestination("default");
    summaryField.setTransform(bold ? summaryField.getTransform().bold() : summaryField.getTransform().unbold());
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 10 with SummaryField

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

the class SummaryNamesFieldCollisions method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    Map<String, Pair<String, String>> fieldToClassAndSource = new HashMap<>();
    for (DocumentSummary summary : search.getSummaries().values()) {
        if ("default".equals(summary.getName()))
            continue;
        for (SummaryField summaryField : summary.getSummaryFields()) {
            if (summaryField.isImplicit())
                continue;
            Pair<String, String> prevClassAndSource = fieldToClassAndSource.get(summaryField.getName());
            for (Source source : summaryField.getSources()) {
                if (prevClassAndSource != null) {
                    String prevClass = prevClassAndSource.getFirst();
                    String prevSource = prevClassAndSource.getSecond();
                    if (!prevClass.equals(summary.getName())) {
                        if (!prevSource.equals(source.getName())) {
                            throw new IllegalArgumentException("For search '" + search.getName() + "', summary class '" + summary.getName() + "'," + " summary field '" + summaryField.getName() + "':" + " Can not use source '" + source.getName() + "' for this summary field, an equally named field in summary class '" + prevClass + "' uses a different source: '" + prevSource + "'.");
                        }
                    }
                } else {
                    fieldToClassAndSource.put(summaryField.getName(), new Pair<>(summary.getName(), source.getName()));
                }
            }
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) HashMap(java.util.HashMap) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) Source(com.yahoo.vespa.documentmodel.SummaryField.Source) Pair(com.yahoo.collections.Pair)

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