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/01 19:38:36 UTC
svn commit: r1717496 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java
solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
Author: jdyer
Date: Tue Dec 1 18:38:36 2015
New Revision: 1717496
URL: http://svn.apache.org/viewvc?rev=1717496&view=rev
Log:
SOLR-8175: fix AIOOBE w/WordBreakSolrSpellChecker
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/WordBreakSolrSpellChecker.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.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=1717496&r1=1717495&r2=1717496&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Tue Dec 1 18:38:36 2015
@@ -17,6 +17,12 @@ New Features
* SOLR-7928: Improve CheckIndex to work against HdfsDirectory
(Mike Drob, Gregory Chanan)
+Bug Fixes
+----------------------
+
+* SOLR-8175: Word Break Spellchecker would throw AIOOBE with certain queries containing
+ "should" clauses. (Ryan Josal via James Dyer)
+
Other Changes
----------------------
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java?rev=1717496&r1=1717495&r2=1717496&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/spelling/WordBreakSolrSpellChecker.java Tue Dec 1 18:38:36 2015
@@ -199,8 +199,8 @@ public class WordBreakSolrSpellChecker e
StringBuilder sb = new StringBuilder();
Token[] tokenArr = options.tokens.toArray(new Token[options.tokens.size()]);
+ List<Token> tokenArrWithSeparators = new ArrayList<>(options.tokens.size() + 2);
List<Term> termArr = new ArrayList<>(options.tokens.size() + 2);
-
List<ResultEntry> breakSuggestionList = new ArrayList<>();
List<ResultEntry> noBreakSuggestionList = new ArrayList<>();
boolean lastOneProhibited = false;
@@ -219,6 +219,7 @@ public class WordBreakSolrSpellChecker e
if (i > 0
&& (prohibited != lastOneProhibited || required != lastOneRequired || lastOneprocedesNewBooleanOp)) {
termArr.add(WordBreakSpellChecker.SEPARATOR_TERM);
+ tokenArrWithSeparators.add(null);
}
lastOneProhibited = prohibited;
lastOneRequired = required;
@@ -226,6 +227,7 @@ public class WordBreakSolrSpellChecker e
Term thisTerm = new Term(field, tokenArr[i].toString());
termArr.add(thisTerm);
+ tokenArrWithSeparators.add(tokenArr[i]);
if (breakWords) {
SuggestWord[][] breakSuggestions = wbsp.suggestWordBreaks(thisTerm,
numSuggestions, ir, options.suggestMode, sortMethod);
@@ -269,10 +271,10 @@ public class WordBreakSolrSpellChecker e
if (i > firstTermIndex) {
sb.append(" ");
}
- sb.append(tokenArr[i].toString());
+ sb.append(tokenArrWithSeparators.get(i).toString());
}
- Token token = new Token(sb.toString(), tokenArr[firstTermIndex]
- .startOffset(), tokenArr[lastTermIndex].endOffset());
+ Token token = new Token(sb.toString(), tokenArrWithSeparators.get(firstTermIndex)
+ .startOffset(), tokenArrWithSeparators.get(lastTermIndex).endOffset());
combineSuggestionList.add(new ResultEntry(token, cs.suggestion.string,
cs.suggestion.freq));
}
Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java?rev=1717496&r1=1717495&r2=1717496&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java Tue Dec 1 18:38:36 2015
@@ -70,6 +70,17 @@ public class WordBreakSolrSpellCheckerTe
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
QueryConverter qc = new SpellingQueryConverter();
qc.setAnalyzer(new MockAnalyzer(random()));
+
+ {
+ //Prior to SOLR-8175, the required term would cause an AIOOBE.
+ Collection<Token> tokens = qc.convert("+pine apple good ness");
+ SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getIndexReader(), 10);
+ SpellingResult result = checker.getSuggestions(spellOpts);
+ searcher.decref();
+ assertTrue(result != null && result.getSuggestions() != null);
+ assertTrue(result.getSuggestions().size()==5);
+ }
+
Collection<Token> tokens = qc.convert("paintable pine apple good ness");
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getIndexReader(), 10);
SpellingResult result = checker.getSuggestions(spellOpts);