You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mk...@apache.org on 2017/01/07 06:18:31 UTC

lucene-solr:master: LUCENE-7614: ComplexPhraseQueryParser ignores quotes around single terms phrases

Repository: lucene-solr
Updated Branches:
  refs/heads/master 024c4031e -> 52f2a77b7


LUCENE-7614: ComplexPhraseQueryParser ignores quotes around single terms phrases


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/52f2a77b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/52f2a77b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/52f2a77b

Branch: refs/heads/master
Commit: 52f2a77b78fc95bc98d664411cda63d58606df52
Parents: 024c403
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Thu Jan 5 23:39:46 2017 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Sat Jan 7 00:42:04 2017 +0300

----------------------------------------------------------------------
 lucene/CHANGES.txt                                             | 3 +++
 .../queryparser/complexPhrase/ComplexPhraseQueryParser.java    | 4 +++-
 .../queryparser/complexPhrase/TestComplexPhraseQuery.java      | 6 ++++++
 3 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52f2a77b/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 67d8ae5..b74056f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -198,6 +198,9 @@ Improvements
 * LUCENE-7401: Changed the way BKD trees pick the split dimension in order to
   ensure all dimensions are indexed. (Adrien Grand)
 
+* LUCENE-7614: Complex Phrase Query parser ignores double quotes around single token 
+  prefix, wildcard, range queries (Mikhail Khludnev) 
+
 Optimizations
 
 * LUCENE-7568: Optimize merging when index sorting is used but the

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52f2a77b/lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java
index 1a7e5e1..6e18960 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java
@@ -255,7 +255,9 @@ public class ComplexPhraseQueryParser extends QueryParser {
     public Query rewrite(IndexReader reader) throws IOException {
       final Query contents = this.contents[0];
       // ArrayList spanClauses = new ArrayList();
-      if (contents instanceof TermQuery) {
+      if (contents instanceof TermQuery 
+          || contents instanceof MultiTermQuery
+          ) {
         return contents;
       }
       // Build a sequence of Span clauses arranged in a SpanNear - child

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/52f2a77b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
index 66078b0..28b600b 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
@@ -72,6 +72,12 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
     checkBadQuery("\"jo* \"smith\" \""); // phrases inside phrases is bad
   }
 
+  public void testSingleTermPhrase() throws Exception {
+    checkMatches("\"joh*\" \"tom\"", "1,2,3,4"); 
+    checkMatches("+\"j*\" +\"tom\"", "4"); 
+    checkMatches("\"jo*\" \"[sma TO smZ]\" ", "1,2,3");
+    checkMatches("+\"j*hn\" +\"sm*h\"", "1,3"); 
+  }
 
   public void testUnOrderedProximitySearches() throws Exception {