Search in sources :

Example 1 with SummaryField

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

the class IndexInfo method derive.

@Override
protected void derive(Search search) {
    // Derive per field
    super.derive(search);
    this.search = search;
    // Populate fieldsets with actual field objects, bit late to do that here but
    for (FieldSet fs : fieldSets.values()) {
        for (String fieldName : fs.getFieldNames()) {
            fs.fields().add(search.getField(fieldName));
        }
    }
    // Must follow, because index settings overrides field settings
    for (Index index : search.getExplicitIndices()) {
        derive(index, search);
    }
    // TODO: Move to fieldinfo and implement differently. This is not right
    for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values()) {
        if (summaryField.getTransform().isTeaser()) {
            addIndexCommand(summaryField.getName(), CMD_DYNTEASER);
        }
        if (summaryField.getTransform().isBolded()) {
            addIndexCommand(summaryField.getName(), CMD_HIGHLIGHT);
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Index(com.yahoo.searchdefinition.Index)

Example 2 with SummaryField

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

the class SDField method getSummaryField.

/**
 * Returns a summary field defined (implicitly or explicitly) by this field.
 *
 * @param create true to create the summary field and add it to this field before returning if it is missing
 * @return the summary field, or null if not present and create is false
 */
public SummaryField getSummaryField(String name, boolean create) {
    SummaryField summaryField = summaryFields.get(name);
    if (summaryField == null && create) {
        summaryField = new SummaryField(name, getDataType());
        addSummaryField(summaryField);
    }
    return summaryFields.get(name);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 3 with SummaryField

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

the class PredicateProcessor method process.

@Override
public void process(boolean validate) {
    for (SDField field : search.allConcreteFields()) {
        if (field.getDataType() == DataType.PREDICATE) {
            if (validate && field.doesIndexing()) {
                fail(search, field, "Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded.");
            }
            if (field.doesAttributing()) {
                Attribute attribute = field.getAttributes().get(field.getName());
                for (Index index : field.getIndices().values()) {
                    BooleanIndexDefinition booleanDefinition = index.getBooleanIndexDefiniton();
                    if (validate && (booleanDefinition == null || !booleanDefinition.hasArity())) {
                        fail(search, field, "Missing arity value in predicate field.");
                    }
                    if (validate && (booleanDefinition.getArity() < 2)) {
                        fail(search, field, "Invalid arity value in predicate field, must be greater than 1.");
                    }
                    double threshold = booleanDefinition.getDensePostingListThreshold();
                    if (validate && (threshold <= 0 || threshold > 1)) {
                        fail(search, field, "Invalid dense-posting-list-threshold value in predicate field. " + "Value must be in range (0..1].");
                    }
                    attribute.setArity(booleanDefinition.getArity());
                    attribute.setLowerBound(booleanDefinition.getLowerBound());
                    attribute.setUpperBound(booleanDefinition.getUpperBound());
                    attribute.setDensePostingListThreshold(threshold);
                    addPredicateOptimizationIlScript(field, booleanDefinition);
                }
                DocumentSummary summary = search.getSummary("attributeprefetch");
                if (summary != null) {
                    summary.remove(attribute.getName());
                }
                for (SummaryField summaryField : search.getSummaryFields(field).values()) {
                    summaryField.setTransform(SummaryTransform.NONE);
                }
            }
        } else if (validate && field.getDataType().getPrimitiveType() == DataType.PREDICATE) {
            fail(search, field, "Collections of predicates are not allowed.");
        } else if (validate && field.getDataType() == DataType.RAW && field.doesIndexing()) {
            fail(search, field, "Indexing of RAW fields is not supported.");
        } else if (validate) {
            // if field is not a predicate, disallow predicate-related index parameters
            for (Index index : field.getIndices().values()) {
                if (index.getBooleanIndexDefiniton() != null) {
                    BooleanIndexDefinition def = index.getBooleanIndexDefiniton();
                    if (def.hasArity()) {
                        fail(search, field, "Arity parameter is used only for predicate type fields.");
                    } else if (def.hasLowerBound() || def.hasUpperBound()) {
                        fail(search, field, "Parameters lower-bound and upper-bound are used only for predicate type fields.");
                    } else if (def.hasDensePostingListThreshold()) {
                        fail(search, field, "Parameter dense-posting-list-threshold is used only for predicate type fields.");
                    }
                }
            }
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Attribute(com.yahoo.searchdefinition.document.Attribute) Index(com.yahoo.searchdefinition.Index) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) BooleanIndexDefinition(com.yahoo.searchdefinition.document.BooleanIndexDefinition)

Example 4 with SummaryField

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

the class SummaryConsistency method assertConsistency.

private void assertConsistency(SummaryField summaryField, Search search, boolean validate) {
    // Compare to default:
    SummaryField existingDefault = search.getSummary("default").getSummaryField(summaryField.getName());
    if (existingDefault != null) {
        if (validate)
            assertConsistentTypes(existingDefault, summaryField);
        makeConsistentWithDefaultOrThrow(existingDefault, summaryField);
    } else {
        // If no default, compare to whichever definition of the field
        SummaryField existing = search.getExplicitSummaryField(summaryField.getName());
        if (existing == null)
            return;
        if (validate)
            assertConsistentTypes(existing, summaryField);
        makeConsistentOrThrow(existing, summaryField, search);
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 5 with SummaryField

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

the class SummaryToOperation method apply.

public void apply(SDField field) {
    SummaryField summary;
    summary = field.getSummaryField(name);
    if (summary == null) {
        summary = new SummaryField(field);
        summary.addSource(field.getName());
        summary.addDestination("default");
        field.addSummaryField(summary);
    }
    summary.setImplicit(false);
    for (String destination : destinations) {
        summary.addDestination(destination);
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

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