diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-12-13 13:58:14 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-12-13 13:58:14 +0100 |
commit | 644793f437d75d47e38c2a1c2bfb2b8bd2542d07 (patch) | |
tree | 5a2930d828229352754001293a6d0c968ce3a088 /document | |
parent | 49dd2469b58193513332f5e93133f882eea87001 (diff) |
Allow exact match on document type only
Diffstat (limited to 'document')
-rw-r--r-- | document/src/main/java/com/yahoo/document/select/DocumentSelector.java | 9 | ||||
-rw-r--r-- | document/src/main/java/com/yahoo/document/select/rule/DocumentNode.java | 16 |
2 files changed, 6 insertions, 19 deletions
diff --git a/document/src/main/java/com/yahoo/document/select/DocumentSelector.java b/document/src/main/java/com/yahoo/document/select/DocumentSelector.java index 371b8f52d23..686a0cb8e4a 100644 --- a/document/src/main/java/com/yahoo/document/select/DocumentSelector.java +++ b/document/src/main/java/com/yahoo/document/select/DocumentSelector.java @@ -9,17 +9,18 @@ import com.yahoo.document.select.parser.TokenMgrException; import com.yahoo.document.select.rule.ExpressionNode; /** - * <p>A document selector is a filter which accepts or rejects documents + * A document selector is a filter which accepts or rejects documents * based on their type and content. A document selector has a textual - * representation which is called the <i>Document Selection Language</i></p> + * representation which is called the + * <a href="https://docs.vespa.ai/en/reference/document-select-language.html">document selection language</a>. * - * <p>Document selectors are multithread safe.</p> + * Document selectors are multithread safe. * * @author bratseth */ public class DocumentSelector { - private ExpressionNode expression; + private final ExpressionNode expression; /** * Creates a document selector from a Document Selection Language string diff --git a/document/src/main/java/com/yahoo/document/select/rule/DocumentNode.java b/document/src/main/java/com/yahoo/document/select/rule/DocumentNode.java index 0c14ea46761..8022adf3fbe 100644 --- a/document/src/main/java/com/yahoo/document/select/rule/DocumentNode.java +++ b/document/src/main/java/com/yahoo/document/select/rule/DocumentNode.java @@ -43,21 +43,7 @@ public class DocumentNode implements ExpressionNode { } public Object evaluate(DocumentOperation op) { - DocumentType doct; - if (op instanceof DocumentPut) { - doct = ((DocumentPut)op).getDocument().getDataType(); - } else if (op instanceof DocumentUpdate) { - doct = ((DocumentUpdate)op).getDocumentType(); - } else if (op instanceof DocumentRemove) { - DocumentRemove removeOp = (DocumentRemove)op; - return (removeOp.getId().getDocType().equals(type) ? op : Boolean.FALSE); - } else if (op instanceof DocumentGet) { - DocumentGet getOp = (DocumentGet)op; - return (getOp.getId().getDocType().equals(type) ? op : Boolean.FALSE); - } else { - throw new IllegalStateException("Document class '" + op.getClass().getName() + "' is not supported."); - } - return doct.isA(this.type) ? op : Boolean.FALSE; + return op.getId().getDocType().equals(type) ? op : false; } public void accept(Visitor visitor) { |