summaryrefslogtreecommitdiffstats
path: root/config-model/src/main
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2020-03-03 13:19:13 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2020-03-03 13:19:13 +0100
commit1e6522311c436bde6e3151b83fbacadc137b9b42 (patch)
treef4f3bd860256d5b4bbd533cb3bcf45db99e70e2b /config-model/src/main
parenta277132980a9bf55e705bb72f079f11d48fbf030 (diff)
Propagate phrase-segmenting to fieldsets
Diffstat (limited to 'config-model/src/main')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java8
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java25
2 files changed, 26 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
index 0b4562ecd5c..2e4cdd706f7 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
@@ -42,7 +42,7 @@ public class TestProperties implements ModelContext.Properties {
private double defaultTermwiseLimit = 1.0;
private Optional<EndpointCertificateSecrets> endpointCertificateSecrets = Optional.empty();
private boolean useNewAthenzFilter = false;
-
+ private boolean usePhraseSegmenting = false;
@Override public boolean multitenant() { return multitenant; }
@Override public ApplicationId applicationId() { return applicationId; }
@@ -63,6 +63,7 @@ public class TestProperties implements ModelContext.Properties {
@Override public double defaultTermwiseLimit() { return defaultTermwiseLimit; }
@Override public boolean useBucketSpaceMetric() { return true; }
@Override public boolean useNewAthenzFilter() { return useNewAthenzFilter; }
+ @Override public boolean usePhraseSegmenting() { return usePhraseSegmenting; }
public TestProperties setDefaultTermwiseLimit(double limit) {
defaultTermwiseLimit = limit;
@@ -114,6 +115,11 @@ public class TestProperties implements ModelContext.Properties {
return this;
}
+ public TestProperties setUsePhraseSegmenting(boolean phraseSegmenting) {
+ this.usePhraseSegmenting = phraseSegmenting;
+ return this;
+ }
+
public static class Spec implements ConfigServerSpec {
private final String hostName;
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
index f30a150aeee..9ae72badf1c 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
@@ -12,6 +12,7 @@ import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.search.config.IndexInfoConfig;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
/**
@@ -301,6 +302,7 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
boolean anyLowerCasing = false;
boolean anyStemming = false;
boolean anyNormalizing = false;
+ String phraseSegmentingCommand = null;
String stemmingCommand = null;
Matching fieldSetMatching = fieldSet.getMatching(); // null if no explicit matching
// First a pass over the fields to read some params to decide field settings implicitly:
@@ -321,8 +323,13 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
if (field.getNormalizing().doRemoveAccents()) {
anyNormalizing = true;
}
- if (fieldSetMatching == null && field.getMatching().getType() != Matching.defaultType)
+ if (fieldSetMatching == null && field.getMatching().getType() != Matching.defaultType) {
fieldSetMatching = field.getMatching();
+ }
+ Optional<String> explicitPhraseSegmentingCommand = field.getQueryCommands().stream().filter(c -> c.startsWith(CMD_PHRASE_SEGMENTING)).findFirst();
+ if (explicitPhraseSegmentingCommand.isPresent()) {
+ phraseSegmentingCommand = explicitPhraseSegmentingCommand.get();
+ }
}
if (anyIndexing && anyAttributing && fieldSet.getMatching() == null) {
// We have both attributes and indexes and no explicit match setting ->
@@ -365,6 +372,11 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
new IndexInfoConfig.Indexinfo.Command.Builder()
.indexname(fieldSet.getName())
.command(CMD_NORMALIZE));
+ if (phraseSegmentingCommand != null)
+ iiB.command(
+ new IndexInfoConfig.Indexinfo.Command.Builder()
+ .indexname(fieldSet.getName())
+ .command(phraseSegmentingCommand));
}
} else {
// Assume only attribute fields
@@ -400,13 +412,14 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
} else if (fieldSetMatching.getType().equals(Matching.Type.TEXT)) {
}
-
}
- if (phraseSegmenting) {
- iiB.command(new IndexInfoConfig.Indexinfo.Command.Builder()
- .indexname(fieldSet.getName())
- .command(CMD_PHRASE_SEGMENTING));
+ if (phraseSegmentingCommand == null
+ && fieldSet.queryCommands().stream().noneMatch(c -> c.startsWith(CMD_PHRASE_SEGMENTING))) { // use default
+ if (phraseSegmenting)
+ iiB.command(new IndexInfoConfig.Indexinfo.Command.Builder()
+ .indexname(fieldSet.getName())
+ .command(CMD_PHRASE_SEGMENTING));
}
}