Search in sources :

Example 1 with SDField

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

the class DefaultRankProfile method getRankSetting.

/**
 * Returns the rank boost value of the given field
 */
public RankSetting getRankSetting(String fieldOrIndex, RankSetting.Type type) {
    RankSetting setting = super.getRankSetting(fieldOrIndex, type);
    if (setting != null)
        return setting;
    SDField field = getSearch().getConcreteField(fieldOrIndex);
    if (field != null) {
        setting = toRankSetting(field, type);
        if (setting != null)
            return setting;
    }
    Index index = getSearch().getIndex(fieldOrIndex);
    if (index != null) {
        setting = toRankSetting(index, type);
        if (setting != null)
            return setting;
    }
    return null;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField)

Example 2 with SDField

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

the class DefaultRankProfile method rankSettings.

/**
 * Returns the names of the fields which have a rank boost setting
 * explicitly in this profile or in fields
 */
public Set<RankSetting> rankSettings() {
    Set<RankSetting> settings = new LinkedHashSet<>(20);
    settings.addAll(this.rankSettings);
    for (SDField field : getSearch().allConcreteFields()) {
        addSetting(field, RankSetting.Type.WEIGHT, settings);
        addSetting(field, RankSetting.Type.RANKTYPE, settings);
        addSetting(field, RankSetting.Type.LITERALBOOST, settings);
        addSetting(field, RankSetting.Type.PREFERBITVECTOR, settings);
    }
    // Foer settings that really pertains to indexes do the explicit indexes too
    for (Index index : getSearch().getExplicitIndices()) {
        addSetting(index, RankSetting.Type.PREFERBITVECTOR, settings);
    }
    return settings;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SDField(com.yahoo.searchdefinition.document.SDField)

Example 3 with SDField

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

the class DocumentModelBuilder method addToModel.

public void addToModel(Search search) {
    // Then we add the search specific stuff
    SearchDef searchDef = new SearchDef(search.getName());
    addSearchFields(search.extraFieldList(), searchDef);
    for (Field f : search.getDocument().fieldSet()) {
        addSearchField((SDField) f, searchDef);
    }
    for (SDField field : search.allConcreteFields()) {
        for (Attribute attribute : field.getAttributes().values()) {
            if (!searchDef.getFields().containsKey(attribute.getName())) {
                searchDef.add(new SearchField(new Field(attribute.getName(), field), !field.getIndices().isEmpty(), true));
            }
        }
    }
    for (Field f : search.getDocument().fieldSet()) {
        addAlias((SDField) f, searchDef);
    }
    model.getSearchManager().add(searchDef);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SearchField(com.yahoo.vespa.documentmodel.SearchField) Field(com.yahoo.document.Field) SearchDef(com.yahoo.vespa.documentmodel.SearchDef) SearchField(com.yahoo.vespa.documentmodel.SearchField) SDField(com.yahoo.searchdefinition.document.SDField) Attribute(com.yahoo.searchdefinition.document.Attribute)

Example 4 with SDField

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

the class Derived method derive.

/**
 * Derives the content of this configuration. This
 * default calls derive(Document) for each document
 * and derive(SDField) for each search definition level field
 * AND sets the name of this to the name of the input search definition
 */
protected void derive(Search search) {
    setName(search.getName());
    derive(search.getDocument(), search);
    for (Index index : search.getExplicitIndices()) {
        derive(index, search);
    }
    for (SDField field : search.allExtraFields()) {
        derive(field, search);
    }
    search.allImportedFields().forEach(importedField -> derive(importedField, search));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) Index(com.yahoo.searchdefinition.Index)

Example 5 with SDField

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

the class Search method getIndex.

/**
 * <p>Returns an index, or null if no index with this name has had some <b>explicit settings</b> applied. Even if
 * this returns null, the index may be implicitly defined by an indexing statement.</p>
 * <p>This will return the
 * index whether it is defined on this search or on one of its fields</p>
 *
 * @param name the name of the index to get
 * @return the index requested
 */
public Index getIndex(String name) {
    List<Index> sameIndices = new ArrayList<>(1);
    Index searchIndex = indices.get(name);
    if (searchIndex != null) {
        sameIndices.add(searchIndex);
    }
    for (SDField field : allConcreteFields()) {
        Index index = field.getIndex(name);
        if (index != null) {
            sameIndices.add(index);
        }
    }
    if (sameIndices.size() == 0) {
        return null;
    }
    if (sameIndices.size() == 1) {
        return sameIndices.get(0);
    }
    return consolidateIndices(sameIndices);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ImmutableImportedSDField(com.yahoo.searchdefinition.document.ImmutableImportedSDField) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) ArrayList(java.util.ArrayList)

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