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;
}
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;
}
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);
}
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));
}
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);
}
Aggregations