lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [02/23] lucene-solr:jira/solr-9959: SOLR-10323: fix to SpellingQueryConverter to properly strip out colons in field-specific queries
Date Tue, 11 Apr 2017 09:19:23 GMT
SOLR-10323: fix to SpellingQueryConverter to properly strip out colons in field-specific queries


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

Branch: refs/heads/jira/solr-9959
Commit: e75a2e6b86bdac5ee86a4c3fa9d2f5e33bfc42d1
Parents: 53aeffa
Author: jdyer1 <jdyer@apache.org>
Authored: Thu Apr 6 12:48:19 2017 -0500
Committer: jdyer1 <jdyer@apache.org>
Committed: Thu Apr 6 12:48:19 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                          |  3 +++
 .../org/apache/solr/spelling/SpellingQueryConverter.java  |  2 +-
 .../apache/solr/spelling/SpellingQueryConverterTest.java  | 10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e75a2e6b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index cebdac5..dcdf486 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -160,6 +160,9 @@ Bug Fixes
 * SOLR-10387: zkTransfer normalizes destination path incorrectly if source is a windows directory

   (gopikannan venugopalsamy, Erick Erickson)
 
+* SOLR-10323: fix to SpellingQueryConverter to properly strip out colons in field-specific
queries.
+  (Amrit Sarkar via James Dyer)
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e75a2e6b/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java b/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
index 6499c50..4cc75b5 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
@@ -89,7 +89,7 @@ public class SpellingQueryConverter extends QueryConverter  {
     NMTOKEN = "([" + sb.toString() + "]|" + SURROGATE_PAIR + ")+";
   }
 
-  final static String PATTERN = "(?:(?!(" + NMTOKEN + ":|[\\^.]\\d+)))[^^.\\s][\\p{L}_\\-0-9]+";
+  final static String PATTERN = "(?:(?!(" + NMTOKEN + ":|[\\^.]\\d+)))[^^.:(\\s][\\p{L}_\\-0-9]+";
   // previous version: Pattern.compile("(?:(?!(\\w+:|\\d+)))\\w+");
   protected Pattern QUERY_REGEX = Pattern.compile(PATTERN);
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e75a2e6b/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
index ed0749f..821fe73 100644
--- a/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
@@ -94,6 +94,16 @@ public class SpellingQueryConverterTest extends LuceneTestCase {
     assertTrue("tokens is null and it shouldn't be", tokens != null);
     assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
     assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
+    
+    String firstKeyword = "value1";
+    String secondKeyword = "value2";
+    original = "field-with-parenthesis:(" + firstKeyword + " " + secondKeyword + ")";
+    tokens = converter.convert(original);
+    assertTrue("tokens is null and it shouldn't be", tokens != null);
+    assertEquals("tokens Size: " + tokens.size() + " is not 2", 2, tokens.size());
+    assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
+    assertTrue("first Token is not " + firstKeyword, new ArrayList<>(tokens).get(0).toString().equals(firstKeyword));
+    assertTrue("second Token is not " + secondKeyword, new ArrayList<>(tokens).get(1).toString().equals(secondKeyword));
   
   }
 
   private boolean isOffsetCorrect(String s, Collection<Token> tokens) {


Mime
View raw message