summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/document
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-07-11 07:59:15 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-07-11 07:59:15 +0000
commita634adac46bad16b989051045e1702bda255600e (patch)
tree3e06bd22e0a97026dcdeb391cdb40fb95ce3aca1 /config-model/src/main/java/com/yahoo/searchdefinition/document
parent9eadbd143c75a5f10b9429deb1ed0d0abc55ff13 (diff)
Setting attribute on a field that has struct or map sub-type(s) is not supported.
Fail instead of silently ignoring it as that makes the user believe it should work.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/document')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
index 8b523211471..c4e0f4cafef 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
@@ -463,12 +463,33 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
}
}
}.visit(indexingScript);
+ } else {
+ if (!getDataType().equals(PositionDataType.INSTANCE) &&
+ !getDataType().equals(DataType.getArray(PositionDataType.INSTANCE)) &&
+ hasAttributeExpression(exp))
+ {
+ throw new IllegalArgumentException("For field '" + getName() + "': Setting attribute on a field that has struct or map sub-type(s) is not supported");
+ }
}
for (SDField structField : getStructFields()) {
structField.setIndexingScript(exp);
}
}
+ private static boolean hasAttributeExpression(ScriptExpression exp) {
+ var visitor = new ExpressionVisitor() {
+ boolean result = false;
+ @Override
+ protected void doVisit(Expression exp) {
+ if (exp instanceof AttributeExpression) {
+ result = true;
+ }
+ }
+ };
+ visitor.visit(exp);
+ return visitor.result;
+ }
+
@Override
public ScriptExpression getIndexingScript() {
return indexingScript;