You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jd...@apache.org on 2015/12/03 17:16:15 UTC
svn commit: r1717796 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/core/ solr/core/src/java/org/apache/solr/spelling/
solr/core/src/test/org/apache/solr/handler/component/
solr/core/src/test/org/apache/solr/spelling/
Author: jdyer
Date: Thu Dec 3 16:16:15 2015
New Revision: 1717796
URL: http://svn.apache.org/viewvc?rev=1717796&view=rev
Log:
SOLR-2556: Fix SpellingQueryConverter to recognize terms consisting only of digits
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1717796&r1=1717795&r2=1717796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Dec 3 16:16:15 2015
@@ -22,6 +22,9 @@ Bug Fixes
* SOLR-8175: Word Break Spellchecker would throw AIOOBE with certain queries containing
"should" clauses. (Ryan Josal via James Dyer)
+
+* SOLR-2556: The default spellcheck query converter was ignoring terms consisting entirely
+ of digits. (James Dyer)
Other Changes
----------------------
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java?rev=1717796&r1=1717795&r2=1717796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/SpellingQueryConverter.java Thu Dec 3 16:16:15 2015
@@ -90,7 +90,7 @@ public class SpellingQueryConverter exte
NMTOKEN = "([" + sb.toString() + "]|" + SURROGATE_PAIR + ")+";
}
- final static String PATTERN = "(?:(?!(" + NMTOKEN + ":|\\d+)))[\\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);
Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1717796&r1=1717795&r2=1717796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java Thu Dec 3 16:16:15 2015
@@ -66,7 +66,7 @@ public class SpellCheckComponentTest ext
assertU((adoc("id", "6", "lowerfilt", "boue")));
assertU((adoc("id", "7", "lowerfilt", "glue")));
assertU((adoc("id", "8", "lowerfilt", "blee")));
- assertU((adoc("id", "9", "lowerfilt", "pixmaa")));
+ assertU((adoc("id", "9", "lowerfilt", "pixmaa 12345")));
assertU((commit()));
}
@@ -97,6 +97,13 @@ public class SpellCheckComponentTest ext
,"/spellcheck=={'suggestions':['documemt',{'numFound':1,'startOffset':0,'endOffset':8,'suggestion':['document']}]}"
);
}
+
+ @Test
+ public void testNumericQuery() throws Exception {
+ assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","12346")
+ ,"/spellcheck=={'suggestions':['12346',{'numFound':1,'startOffset':0,'endOffset':5,'suggestion':['12345']}]}"
+ );
+ }
@Test
Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java?rev=1717796&r1=1717795&r2=1717796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java Thu Dec 3 16:16:15 2015
@@ -45,7 +45,21 @@ public class SpellingQueryConverterTest
assertTrue("tokens is null and it shouldn't be", tokens != null);
assertTrue("tokens Size: " + tokens.size() + " is not: " + 1, tokens.size() == 1);
}
-
+
+ @Test
+ public void testNumeric() throws Exception {
+ SpellingQueryConverter converter = new SpellingQueryConverter();
+ converter.init(new NamedList());
+ converter.setAnalyzer(new WhitespaceAnalyzer());
+ String[] queries = {"12345", "foo:12345", "12345 67890", "foo:(12345 67890)", "foo:(life 67890)", "12345 life",
+ "+12345 +life", "-12345 life"};
+ int[] tokensToExpect = {1, 1, 2, 2, 2, 2, 2, 2};
+ for (int i = 0; i < queries.length; i++) {
+ Collection<Token> tokens = converter.convert(queries[i]);
+ assertTrue("tokens Size: " + tokens.size() + " is not: " + tokensToExpect[i], tokens.size() == tokensToExpect[i]);
+ }
+ }
+
@Test
public void testSpecialChars() {
SpellingQueryConverter converter = new SpellingQueryConverter();