summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/derived
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-08-24 18:39:36 +0200
committerJon Bratseth <bratseth@oath.com>2018-08-24 18:39:36 +0200
commit35e957f09c4018c2e1bab70da2e632130b0b43e6 (patch)
treeccc5414c93737c7b4ca3cd4362043ca65d9d12e3 /config-model/src/main/java/com/yahoo/searchdefinition/derived
parent0c1bd91225452980d79f7a9a38d1e5fa5aba8644 (diff)
Generate a global rank profile config
This makes available to all regular container clusters a config containing a set of rank profiles containing the expressions resulting from converting all the ml models added in the models/ directory in the application package.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/derived')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java5
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java24
2 files changed, 20 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
index 55f3a94bb70..a3580a404a3 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
@@ -41,8 +41,11 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce
/** Whether this has any position attribute */
private boolean hasPosition = false;
+ public static final AttributeFields empty = new AttributeFields(null);
+
public AttributeFields(Search search) {
- derive(search);
+ if (search != null)
+ derive(search);
}
/** Derives everything from a field */
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index a0bac42d9b9..0417a879969 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -12,11 +12,16 @@ import java.util.Map;
/**
* The derived rank profiles of a search definition
*
- * @author bratseth
+ * @author bratseth
*/
public class RankProfileList extends Derived implements RankProfilesConfig.Producer {
- private Map<String, RawRankProfile> rankProfiles = new java.util.LinkedHashMap<>();
+ private final Map<String, RawRankProfile> rankProfiles = new java.util.LinkedHashMap<>();
+
+ public static RankProfileList empty = new RankProfileList();
+
+ private RankProfileList() {
+ }
/**
* Creates a rank profile
@@ -29,7 +34,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
RankProfileRegistry rankProfileRegistry,
QueryProfileRegistry queryProfiles,
ImportedModels importedModels) {
- setName(search.getName());
+ setName(search == null ? "default" : search.getName());
deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, search, attributeFields);
}
@@ -38,11 +43,13 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
ImportedModels importedModels,
Search search,
AttributeFields attributeFields) {
- RawRankProfile defaultProfile = new RawRankProfile(rankProfileRegistry.get(search, "default"),
- queryProfiles,
- importedModels,
- attributeFields);
- rankProfiles.put(defaultProfile.getName(), defaultProfile);
+ if (search != null) { // profiles belonging to a search have a default profile
+ RawRankProfile defaultProfile = new RawRankProfile(rankProfileRegistry.get(search, "default"),
+ queryProfiles,
+ importedModels,
+ attributeFields);
+ rankProfiles.put(defaultProfile.getName(), defaultProfile);
+ }
for (RankProfile rank : rankProfileRegistry.rankProfilesOf(search)) {
if ("default".equals(rank.getName())) continue;
@@ -70,4 +77,5 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
rank.getConfig(builder);
}
}
+
}