Search in sources :

Example 11 with SDField

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

the class StemmingResolver method checkStemmingForIndexFields.

private void checkStemmingForIndexFields(String indexName, List<SDField> fields) {
    Stemming stemming = null;
    SDField stemmingField = null;
    for (SDField field : fields) {
        if (stemming == null && stemmingField == null) {
            stemming = field.getStemming(search);
            stemmingField = field;
        } else if (stemming != field.getStemming(search)) {
            deployLogger.log(Level.WARNING, "Field '" + field.getName() + "' has " + field.getStemming(search) + ", whereas field '" + stemmingField.getName() + "' has " + stemming + ". All fields indexing to the index '" + indexName + "' must have the same stemming." + " This should be corrected as it will make indexing fail in a few cases.");
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Stemming(com.yahoo.searchdefinition.document.Stemming)

Example 12 with SDField

use of com.yahoo.searchdefinition.document.SDField 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 13 with SDField

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

the class Processor method addField.

/**
 * Convenience method for adding a no-strings-attached implementation field for a regular field
 *
 * @param search       the search definition in question
 * @param field        the field to add an implementation field for
 * @param suffix       the suffix of the added implementation field (without the underscore)
 * @param indexing     the indexing statement of the field
 * @param queryCommand the query command of the original field, or null if none
 * @return the implementation field which is added to the search
 */
protected SDField addField(Search search, SDField field, String suffix, String indexing, String queryCommand) {
    SDField implementationField = search.getConcreteField(field.getName() + "_" + suffix);
    if (implementationField != null) {
        deployLogger.log(Level.WARNING, "Implementation field " + implementationField + " added twice");
    } else {
        implementationField = new SDField(search.getDocument(), field.getName() + "_" + suffix, DataType.STRING);
    }
    implementationField.setRankType(RankType.EMPTY);
    implementationField.setStemming(Stemming.NONE);
    implementationField.getNormalizing().inferCodepoint();
    implementationField.parseIndexingScript(indexing);
    for (Iterator i = field.getFieldNameAsIterator(); i.hasNext(); ) {
        String indexName = (String) i.next();
        String implementationIndexName = indexName + "_" + suffix;
        Index implementationIndex = new Index(implementationIndexName);
        search.addIndex(implementationIndex);
    }
    if (queryCommand != null) {
        field.addQueryCommand(queryCommand);
    }
    search.addExtraField(implementationField);
    search.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, implementationField.getName());
    return implementationField;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Iterator(java.util.Iterator) Index(com.yahoo.searchdefinition.Index)

Example 14 with SDField

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

the class ReferenceFieldsProcessor method clearSummaryAttributeAspectForConcreteFields.

private void clearSummaryAttributeAspectForConcreteFields() {
    for (SDField field : search.allConcreteFields()) {
        if (field.getDataType() instanceof ReferenceDataType) {
            removeFromAttributePrefetchSummaryClass(field);
            clearSummaryTransformOnSummaryFields(field);
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ReferenceDataType(com.yahoo.document.ReferenceDataType)

Example 15 with SDField

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

the class ImportedFieldsResolver method resolveImportedField.

private void resolveImportedField(TemporaryImportedField importedField, boolean validate) {
    DocumentReference reference = validateDocumentReference(importedField);
    SDField targetField = validateTargetField(importedField, reference, validate);
    importedFields.put(importedField.fieldName(), new ImportedField(importedField.fieldName(), reference, targetField));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TemporaryImportedField(com.yahoo.searchdefinition.document.TemporaryImportedField) ImportedField(com.yahoo.searchdefinition.document.ImportedField) DocumentReference(com.yahoo.searchdefinition.DocumentReference)

Aggregations

SDField (com.yahoo.searchdefinition.document.SDField)85 Test (org.junit.Test)33 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)22 Search (com.yahoo.searchdefinition.Search)15 Attribute (com.yahoo.searchdefinition.document.Attribute)11 Index (com.yahoo.searchdefinition.Index)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 ArrayList (java.util.ArrayList)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 Field (com.yahoo.document.Field)6 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)6 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)5 ArrayDataType (com.yahoo.document.ArrayDataType)4 DataType (com.yahoo.document.DataType)4 DocumentReference (com.yahoo.searchdefinition.DocumentReference)4 RankProfile (com.yahoo.searchdefinition.RankProfile)4 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4