From 8b396d82ce6e8e5287f4279042ae41ab6ff858b6 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Wed, 28 Oct 2015 09:45:14 +0000 Subject: [PATCH] LUCENE-6857: Validate StandardQueryParser with NOT operator with-in parantheses git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1710970 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../queryparser/flexible/standard/TestQPHelper.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 6aec45ff109..92fa303281c 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -227,6 +227,9 @@ Bug Fixes Other +* LUCENE-6857: Validate StandardQueryParser with NOT operator + with-in parantheses. (Jigar Shah via Dawid Weiss) + * LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList in MultiFieldQueryNodeProcessor. (Dawid Weiss). diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java index ee29952882c..bb6c0a37223 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java @@ -538,7 +538,18 @@ public class TestQPHelper extends LuceneTestCase { assertQueryEquals("!term", null, "-term"); assertQueryEquals("NOT term", null, "-term"); } - + + public void testNegationInParentheses() throws Exception { + assertQueryEquals("(-a)", null, "-a"); + assertQueryEquals("(!a)", null, "-a"); + assertQueryEquals("(NOT a)", null, "-a"); + assertQueryEquals("a (!b)", null, "a (-b)"); + assertQueryEquals("+a +(!b)", null, "+a +(-b)"); + assertQueryEquals("a AND (!b)", null, "+a +(-b)"); + assertQueryEquals("a (NOT b)", null, "a (-b)"); + assertQueryEquals("a AND (NOT b)", null, "+a +(-b)"); + } + public void testWildcard() throws Exception { assertQueryEquals("term*", null, "term*"); assertQueryEquals("term*^2", null, "(term*)^2.0");