aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/parser
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/main/java/com/yahoo/schema/parser')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedFields.java1
-rw-r--r--config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedRanking.java62
-rw-r--r--config-model/src/main/java/com/yahoo/schema/parser/IntermediateCollection.java4
-rw-r--r--config-model/src/main/java/com/yahoo/schema/parser/ParsedMatchSettings.java3
-rw-r--r--config-model/src/main/java/com/yahoo/schema/parser/ParsedRankProfile.java31
5 files changed, 56 insertions, 45 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedFields.java b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedFields.java
index 7659a1e6562..173eebe2a94 100644
--- a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedFields.java
+++ b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedFields.java
@@ -44,6 +44,7 @@ public class ConvertParsedFields {
parsed.getGramSize().ifPresent(gramSize -> field.getMatching().setGramSize(gramSize));
parsed.getMaxLength().ifPresent(maxLength -> field.getMatching().maxLength(maxLength));
parsed.getMaxTermOccurrences().ifPresent(maxTermOccurrences -> field.getMatching().maxTermOccurrences(maxTermOccurrences));
+ parsed.getMaxTokenLength().ifPresent(maxTokenLength -> field.getMatching().maxTokenLength(maxTokenLength));
parsed.getMatchAlgorithm().ifPresent
(matchingAlgorithm -> field.setMatchingAlgorithm(matchingAlgorithm));
parsed.getExactTerminator().ifPresent
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedRanking.java b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedRanking.java
index 5ccbb7b19a4..ff78a4a3b60 100644
--- a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedRanking.java
+++ b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedRanking.java
@@ -38,7 +38,8 @@ public class ConvertParsedRanking {
for (String name : parsed.getInherited())
profile.inherit(name);
- parsed.isStrict().ifPresent(value -> profile.setStrict(value));
+ parsed.isStrict().ifPresent(profile::setStrict);
+ parsed.isUseSignificanceModel().ifPresent(profile::setUseSignificanceModel);
for (var constant : parsed.getConstants().values())
profile.add(constant);
@@ -57,39 +58,26 @@ public class ConvertParsedRanking {
profile.addFunction(name, parameters, expression, inline);
}
- parsed.getRankScoreDropLimit().ifPresent
- (value -> profile.setRankScoreDropLimit(value));
- parsed.getTermwiseLimit().ifPresent
- (value -> profile.setTermwiseLimit(value));
- parsed.getPostFilterThreshold().ifPresent
- (value -> profile.setPostFilterThreshold(value));
- parsed.getApproximateThreshold().ifPresent
- (value -> profile.setApproximateThreshold(value));
- parsed.getTargetHitsMaxAdjustmentFactor().ifPresent
- (value -> profile.setTargetHitsMaxAdjustmentFactor(value));
- parsed.getKeepRankCount().ifPresent
- (value -> profile.setKeepRankCount(value));
- parsed.getMinHitsPerThread().ifPresent
- (value -> profile.setMinHitsPerThread(value));
- parsed.getNumSearchPartitions().ifPresent
- (value -> profile.setNumSearchPartitions(value));
- parsed.getNumThreadsPerSearch().ifPresent
- (value -> profile.setNumThreadsPerSearch(value));
- parsed.getReRankCount().ifPresent
- (value -> profile.setRerankCount(value));
-
- parsed.getMatchPhaseSettings().ifPresent
- (value -> profile.setMatchPhaseSettings(value));
-
- parsed.getFirstPhaseExpression().ifPresent
- (value -> profile.setFirstPhaseRanking(value));
- parsed.getSecondPhaseExpression().ifPresent
- (value -> profile.setSecondPhaseRanking(value));
-
- parsed.getGlobalPhaseExpression().ifPresent
- (value -> profile.setGlobalPhaseRanking(value));
- parsed.getGlobalPhaseRerankCount().ifPresent
- (value -> profile.setGlobalPhaseRerankCount(value));
+ parsed.getRankScoreDropLimit().ifPresent(profile::setRankScoreDropLimit);
+ parsed.getSecondPhaseRankScoreDropLimit().ifPresent(profile::setSecondPhaseRankScoreDropLimit);
+ parsed.getTermwiseLimit().ifPresent(profile::setTermwiseLimit);
+ parsed.getPostFilterThreshold().ifPresent(profile::setPostFilterThreshold);
+ parsed.getApproximateThreshold().ifPresent(profile::setApproximateThreshold);
+ parsed.getTargetHitsMaxAdjustmentFactor().ifPresent(profile::setTargetHitsMaxAdjustmentFactor);
+ parsed.getKeepRankCount().ifPresent(profile::setKeepRankCount);
+ parsed.getMinHitsPerThread().ifPresent(profile::setMinHitsPerThread);
+ parsed.getNumSearchPartitions().ifPresent(profile::setNumSearchPartitions);
+ parsed.getNumThreadsPerSearch().ifPresent(profile::setNumThreadsPerSearch);
+ parsed.getReRankCount().ifPresent(profile::setRerankCount);
+
+ parsed.getMatchPhase().ifPresent(profile::setMatchPhase);
+ parsed.getDiversity().ifPresent(profile::setDiversity);
+
+ parsed.getFirstPhaseExpression().ifPresent(profile::setFirstPhaseRanking);
+ parsed.getSecondPhaseExpression().ifPresent(profile::setSecondPhaseRanking);
+
+ parsed.getGlobalPhaseExpression().ifPresent(profile::setGlobalPhaseRanking);
+ parsed.getGlobalPhaseRerankCount().ifPresent(profile::setGlobalPhaseRerankCount);
for (var value : parsed.getMatchFeatures()) {
profile.addMatchFeatures(value);
@@ -101,10 +89,8 @@ public class ConvertParsedRanking {
profile.addSummaryFeatures(value);
}
- parsed.getInheritedMatchFeatures().ifPresent
- (value -> profile.setInheritedMatchFeatures(value));
- parsed.getInheritedSummaryFeatures().ifPresent
- (value -> profile.setInheritedSummaryFeatures(value));
+ parsed.getInheritedMatchFeatures().ifPresent(profile::setInheritedMatchFeatures);
+ parsed.getInheritedSummaryFeatures().ifPresent(profile::setInheritedSummaryFeatures);
if (parsed.getIgnoreDefaultRankFeatures()) {
profile.setIgnoreDefaultRankFeatures(true);
}
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/IntermediateCollection.java b/config-model/src/main/java/com/yahoo/schema/parser/IntermediateCollection.java
index 789f7023aed..063962bf0c4 100644
--- a/config-model/src/main/java/com/yahoo/schema/parser/IntermediateCollection.java
+++ b/config-model/src/main/java/com/yahoo/schema/parser/IntermediateCollection.java
@@ -133,9 +133,9 @@ public class IntermediateCollection {
var parser = new SchemaParser(stream, deployLogger, modelProperties);
try {
parser.rankProfile(schema);
- } catch (ParseException pe) {
+ } catch (ParseException | TokenMgrException e) {
throw new ParseException("Failed parsing rank-profile from '" + reader.getName() + "': " +
- stream.formatException(Exceptions.toMessageString(pe)));
+ stream.formatException(Exceptions.toMessageString(e)));
}
} catch (java.io.IOException ex) {
throw new IllegalArgumentException("Failed reading from '" + reader.getName() + "': " + ex.getMessage());
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ParsedMatchSettings.java b/config-model/src/main/java/com/yahoo/schema/parser/ParsedMatchSettings.java
index c7d1a215ce3..bac2c894283 100644
--- a/config-model/src/main/java/com/yahoo/schema/parser/ParsedMatchSettings.java
+++ b/config-model/src/main/java/com/yahoo/schema/parser/ParsedMatchSettings.java
@@ -23,6 +23,7 @@ public class ParsedMatchSettings {
private Integer gramSize = null;
private Integer maxLength = null;
private Integer maxTermOccurrences = null;
+ private Integer maxTokenLength = null;
Optional<MatchType> getMatchType() { return Optional.ofNullable(matchType); }
Optional<Case> getMatchCase() { return Optional.ofNullable(matchCase); }
@@ -31,6 +32,7 @@ public class ParsedMatchSettings {
Optional<Integer> getGramSize() { return Optional.ofNullable(gramSize); }
Optional<Integer> getMaxLength() { return Optional.ofNullable(maxLength); }
Optional<Integer> getMaxTermOccurrences() { return Optional.ofNullable(maxTermOccurrences); }
+ Optional<Integer> getMaxTokenLength() { return Optional.ofNullable(maxTokenLength); }
// TODO - consider allowing each set only once:
void setType(MatchType value) { this.matchType = value; }
@@ -40,5 +42,6 @@ public class ParsedMatchSettings {
void setGramSize(int value) { this.gramSize = value; }
void setMaxLength(int value) { this.maxLength = value; }
void setMaxTermOccurrences(int value) { this.maxTermOccurrences = value; }
+ void setMaxTokenLength(int value) { this.maxTokenLength = value; }
}
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ParsedRankProfile.java b/config-model/src/main/java/com/yahoo/schema/parser/ParsedRankProfile.java
index fbbb0c7fe83..2a117a4af4b 100644
--- a/config-model/src/main/java/com/yahoo/schema/parser/ParsedRankProfile.java
+++ b/config-model/src/main/java/com/yahoo/schema/parser/ParsedRankProfile.java
@@ -4,6 +4,7 @@ package com.yahoo.schema.parser;
import com.yahoo.schema.OnnxModel;
import com.yahoo.schema.RankProfile;
import com.yahoo.schema.RankProfile.MatchPhaseSettings;
+import com.yahoo.schema.RankProfile.DiversitySettings;
import com.yahoo.schema.RankProfile.MutateOperation;
import com.yahoo.searchlib.rankingexpression.FeatureList;
import com.yahoo.searchlib.rankingexpression.Reference;
@@ -26,6 +27,7 @@ class ParsedRankProfile extends ParsedBlock {
private boolean ignoreDefaultRankFeatures = false;
private Double rankScoreDropLimit = null;
+ private Double secondPhaseRankScoreDropLimit = null;
private Double termwiseLimit = null;
private Double postFilterThreshold = null;
private Double approximateThreshold = null;
@@ -38,12 +40,14 @@ class ParsedRankProfile extends ParsedBlock {
private Integer numSearchPartitions = null;
private Integer numThreadsPerSearch = null;
private Integer reRankCount = null;
- private MatchPhaseSettings matchPhaseSettings = null;
+ private MatchPhaseSettings matchPhase = null;
+ private DiversitySettings diversity = null;
private String firstPhaseExpression = null;
private String inheritedSummaryFeatures = null;
private String inheritedMatchFeatures = null;
private String secondPhaseExpression = null;
private Boolean strict = null;
+ private Boolean useSignificanceModel = null;
private final List<MutateOperation> mutateOperations = new ArrayList<>();
private final List<String> inherited = new ArrayList<>();
private final Map<String, Boolean> fieldsRankFilter = new LinkedHashMap<>();
@@ -63,6 +67,7 @@ class ParsedRankProfile extends ParsedBlock {
boolean getIgnoreDefaultRankFeatures() { return this.ignoreDefaultRankFeatures; }
Optional<Double> getRankScoreDropLimit() { return Optional.ofNullable(this.rankScoreDropLimit); }
+ Optional<Double> getSecondPhaseRankScoreDropLimit() { return Optional.ofNullable(this.secondPhaseRankScoreDropLimit); }
Optional<Double> getTermwiseLimit() { return Optional.ofNullable(this.termwiseLimit); }
Optional<Double> getPostFilterThreshold() { return Optional.ofNullable(this.postFilterThreshold); }
Optional<Double> getApproximateThreshold() { return Optional.ofNullable(this.approximateThreshold); }
@@ -75,7 +80,8 @@ class ParsedRankProfile extends ParsedBlock {
Optional<Integer> getNumSearchPartitions() { return Optional.ofNullable(this.numSearchPartitions); }
Optional<Integer> getNumThreadsPerSearch() { return Optional.ofNullable(this.numThreadsPerSearch); }
Optional<Integer> getReRankCount() { return Optional.ofNullable(this.reRankCount); }
- Optional<MatchPhaseSettings> getMatchPhaseSettings() { return Optional.ofNullable(this.matchPhaseSettings); }
+ Optional<MatchPhaseSettings> getMatchPhase() { return Optional.ofNullable(this.matchPhase); }
+ Optional<DiversitySettings> getDiversity() { return Optional.ofNullable(this.diversity); }
Optional<String> getFirstPhaseExpression() { return Optional.ofNullable(this.firstPhaseExpression); }
Optional<String> getInheritedMatchFeatures() { return Optional.ofNullable(this.inheritedMatchFeatures); }
List<ParsedRankFunction> getFunctions() { return List.copyOf(functions.values()); }
@@ -96,6 +102,8 @@ class ParsedRankProfile extends ParsedBlock {
Optional<String> getSecondPhaseExpression() { return Optional.ofNullable(this.secondPhaseExpression); }
Optional<Boolean> isStrict() { return Optional.ofNullable(this.strict); }
+ Optional<Boolean> isUseSignificanceModel() { return Optional.ofNullable(this.useSignificanceModel); }
+
void addSummaryFeatures(FeatureList features) { this.summaryFeatures.add(features); }
void addMatchFeatures(FeatureList features) { this.matchFeatures.add(features); }
void addRankFeatures(FeatureList features) { this.rankFeatures.add(features); }
@@ -168,9 +176,13 @@ class ParsedRankProfile extends ParsedBlock {
this.keepRankCount = count;
}
- void setMatchPhaseSettings(MatchPhaseSettings settings) {
- verifyThat(matchPhaseSettings == null, "already has match-phase");
- this.matchPhaseSettings = settings;
+ void setMatchPhase(MatchPhaseSettings settings) {
+ verifyThat(matchPhase == null, "already has match-phase");
+ this.matchPhase = settings;
+ }
+ void setDiversity(DiversitySettings settings) {
+ verifyThat(diversity == null, "already has diversity");
+ this.diversity = settings;
}
void setMinHitsPerThread(int minHits) {
@@ -193,6 +205,11 @@ class ParsedRankProfile extends ParsedBlock {
this.rankScoreDropLimit = limit;
}
+ void setSecondPhaseRankScoreDropLimit(double limit) {
+ verifyThat(secondPhaseRankScoreDropLimit == null, "already has rank-score-drop-limit for second phase");
+ this.secondPhaseRankScoreDropLimit = limit;
+ }
+
void setRerankCount(int count) {
verifyThat(reRankCount == null, "already has rerank-count");
this.reRankCount = count;
@@ -218,6 +235,10 @@ class ParsedRankProfile extends ParsedBlock {
this.strict = strict;
}
+ void setUseSignificanceModel(boolean useSignificanceModel) {
+ verifyThat(this.useSignificanceModel == null, "already has use-model");
+ this.useSignificanceModel = useSignificanceModel;
+ }
void setTermwiseLimit(double limit) {
verifyThat(termwiseLimit == null, "already has termwise-limit");
this.termwiseLimit = limit;