diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/yql')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/yql/YqlParser.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java index a81f90aa18e..c0c5b0ee0b0 100644 --- a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java +++ b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java @@ -356,6 +356,8 @@ public class YqlParser implements Parser { return buildFunctionCall(ast); case LITERAL: return buildLiteral(ast); + case NOT: + return buildNot(ast); default: throw newUnexpectedArgumentException(ast.getOperator(), ExpressionOperator.AND, ExpressionOperator.CALL, @@ -1096,17 +1098,21 @@ public class YqlParser implements Parser { AndItem andItem = new AndItem(); NotItem notItem = new NotItem(); convertVarArgsAnd(ast, 0, andItem, notItem); - Preconditions - .checkArgument(andItem.getItemCount() > 0, - "Vespa does not support AND with no logically positive branches."); if (notItem.getItemCount() == 0) { return andItem; } if (andItem.getItemCount() == 1) { notItem.setPositiveItem(andItem.getItem(0)); - } else { + } else if (andItem.getItemCount() > 1) { notItem.setPositiveItem(andItem); - } + } // else no positives, which is ok + return notItem; + } + + /** Build a "pure" not, without any positive terms. */ + private CompositeItem buildNot(OperatorNode<ExpressionOperator> ast) { + NotItem notItem = new NotItem(); + notItem.addNegativeItem(convertExpression(ast.getArgument(0))); return notItem; } |