Search in sources :

Example 71 with SDField

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

the class ImportedFieldsResolver method validateTargetField.

private SDField validateTargetField(TemporaryImportedField importedField, DocumentReference reference, boolean validate) {
    String targetFieldName = importedField.targetFieldName();
    Search targetSearch = reference.targetSearch();
    if (validate && isImportedField(targetSearch, targetFieldName)) {
        fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is an imported field. Not supported");
    }
    SDField targetField = targetSearch.getConcreteField(targetFieldName);
    if (targetField == null) {
        fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Not found");
    } else if (!targetField.doesAttributing()) {
        if (validate)
            fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is not an attribute field. Only attribute fields supported");
    } else if (targetField.doesIndexing()) {
        if (validate)
            fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Is an index field. Not supported");
    }
    return targetField;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search)

Example 72 with SDField

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

the class LiteralBoost method reduceFieldLiteralBoost.

private void reduceFieldLiteralBoost(SDField field, Search search) {
    SDField literalField = addField(search, field, "literal", "{ input " + field.getName() + " | tokenize | index " + field.getName() + "_literal; }", "literal-boost");
    literalField.setWeight(field.getWeight() + field.getLiteralBoost());
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField)

Example 73 with SDField

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

the class MultifieldIndexHarmonizer method populateIndexToFields.

private void populateIndexToFields(Search search) {
    for (SDField field : search.allConcreteFields()) {
        if (!field.doesIndexing())
            continue;
        for (Iterator j = field.getFieldNameAsIterator(); j.hasNext(); ) {
            String indexName = (String) j.next();
            addIndexField(indexName, field);
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Iterator(java.util.Iterator)

Example 74 with SDField

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

the class SetLanguage method process.

@Override
public void process(boolean validate) {
    List<String> textFieldsWithoutLanguage = new ArrayList<>();
    for (SDField field : search.allConcreteFields()) {
        if (fieldMustComeAfterLanguageSettingField(field)) {
            textFieldsWithoutLanguage.add(field.getName());
        }
        if (field.containsExpression(SetLanguageExpression.class) && !textFieldsWithoutLanguage.isEmpty()) {
            StringBuilder fieldString = new StringBuilder();
            for (String fieldName : textFieldsWithoutLanguage) {
                fieldString.append(fieldName).append(" ");
            }
            warn(search, field, "Field '" + field.getName() + "' sets the language for this document, " + "and should be defined as the first field in the searchdefinition." + "Preceding text fields that will not have their language set: " + fieldString.toString() + " (This warning is omitted for any subsequent fields that also do set_language.)");
            return;
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ArrayList(java.util.ArrayList) SetLanguageExpression(com.yahoo.vespa.indexinglanguage.expressions.SetLanguageExpression)

Example 75 with SDField

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

the class FilterFieldNames method process.

@Override
public void process(boolean validate) {
    for (SDField f : search.allConcreteFields()) {
        if (f.getRanking().isFilter()) {
            filterField(f.getName());
        }
    }
    for (RankProfile profile : rankProfileRegistry.localRankProfiles(search)) {
        Set<String> filterFields = new LinkedHashSet<>();
        findFilterFields(search, profile, filterFields);
        for (Iterator<String> itr = filterFields.iterator(); itr.hasNext(); ) {
            String fieldName = itr.next();
            profile.filterFields().add(fieldName);
            profile.addRankSetting(fieldName, RankProfile.RankSetting.Type.RANKTYPE, RankType.EMPTY);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SDField(com.yahoo.searchdefinition.document.SDField) RankProfile(com.yahoo.searchdefinition.RankProfile)

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