summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-08-05 16:49:35 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-08-05 16:49:35 +0200
commitc9948e8a8ce64f5ae819adc9e9ff2834700c582e (patch)
tree2a700dd9512193d5543feee4ba05d9fb3cb433f9 /config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java
parent00eda613b439d53facdcc3d261b828454446faa0 (diff)
Allow both attribute and index with n-gram
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java
index 3f3fc11380b..35c123de78f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java
@@ -36,12 +36,12 @@ public class NGramMatch extends Processor {
}
private void implementGramMatch(Search search, SDField field, boolean validate) {
- if (validate && field.doesAttributing())
- throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' not 'attribute' in indexing");
+ if (validate && field.doesAttributing() && ! field.doesIndexing())
+ throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' in indexing");
int n = field.getMatching().getGramSize();
if (n < 0)
- n=DEFAULT_GRAM_SIZE; // not set - use default gram size
+ n = DEFAULT_GRAM_SIZE; // not set - use default gram size
if (validate && n == 0)
throw new IllegalArgumentException("Illegal gram size in " + field + ": Must be at least 1");
field.getNormalizing().inferCodepoint();
@@ -67,9 +67,8 @@ public class NGramMatch extends Processor {
@Override
protected Expression newTransform(DataType fieldType) {
Expression exp = new NGramExpression(null, ngram);
- if (fieldType instanceof CollectionDataType) {
+ if (fieldType instanceof CollectionDataType)
exp = new ForEachExpression(exp);
- }
return exp;
}