LUCENE-2580: fix AIOOBE in MultiPhraseQuery

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@980911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-07-30 18:27:40 +00:00
parent bea5529ed4
commit 1904003fac
1 changed files with 5 additions and 5 deletions

View File

@ -175,8 +175,8 @@ public class MultiPhraseQuery extends Query {
PhraseQuery.PostingsAndFreq[] postingsFreqs = new PhraseQuery.PostingsAndFreq[termArrays.size()]; PhraseQuery.PostingsAndFreq[] postingsFreqs = new PhraseQuery.PostingsAndFreq[termArrays.size()];
for (int i=0; i<postingsFreqs.length; i++) { for (int pos=0; pos<postingsFreqs.length; pos++) {
Term[] terms = termArrays.get(i); Term[] terms = termArrays.get(pos);
final DocsAndPositionsEnum postingsEnum; final DocsAndPositionsEnum postingsEnum;
int docFreq; int docFreq;
@ -187,8 +187,8 @@ public class MultiPhraseQuery extends Query {
// coarse -- this overcounts since a given doc can // coarse -- this overcounts since a given doc can
// have more than one terms: // have more than one terms:
docFreq = 0; docFreq = 0;
for(int j=0;j<terms.length;j++) { for(int termIdx=0;termIdx<terms.length;termIdx++) {
docFreq += reader.docFreq(terms[i]); docFreq += reader.docFreq(terms[termIdx]);
} }
} else { } else {
final BytesRef text = new BytesRef(terms[0].text()); final BytesRef text = new BytesRef(terms[0].text());
@ -209,7 +209,7 @@ public class MultiPhraseQuery extends Query {
docFreq = reader.docFreq(terms[0].field(), text); docFreq = reader.docFreq(terms[0].field(), text);
} }
postingsFreqs[i] = new PhraseQuery.PostingsAndFreq(postingsEnum, docFreq, positions.get(i).intValue()); postingsFreqs[pos] = new PhraseQuery.PostingsAndFreq(postingsEnum, docFreq, positions.get(pos).intValue());
} }
// sort by increasing docFreq order // sort by increasing docFreq order