You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by jayendra patil <ja...@gmail.com> on 2010/07/30 17:20:40 UTC

MultiPhraseQuery throws ArrayIndexOutOfBounds Exception

Working on the nightly build of solr and lucene -

MultiPhraseQuery throws ArrayIndexOutOfBounds Exception for the words
defined as synonyms

SEVERE: java.lang.ArrayIndexOutOfBoundsException: 5
    at
org.apache.lucene.search.MultiPhraseQuery$MultiPhraseWeight.scorer(MultiPhraseQuery.java:191)

        if (terms.length > 1) {
          postingsEnum = new UnionDocsAndPositionsEnum(reader, terms);

          // coarse -- this overcounts since a given doc can
          // have more than one terms:
          docFreq = 0;
          for(int j=0;j<terms.length;j++) {
            // Should be j
            docFreq += reader.docFreq(terms[*i*]);
          }
        } else {

The for loop seems to iterate on terms length with variable j, but refers to
i within the loop which is iterating on the search terms count.

Regards,
Jayendra

Re: MultiPhraseQuery throws ArrayIndexOutOfBounds Exception

Posted by Michael McCandless <lu...@mikemccandless.com>.
Nice catch -- thanks!  I will fix.

Mike

On Fri, Jul 30, 2010 at 11:20 AM, jayendra patil
<ja...@gmail.com> wrote:
> Working on the nightly build of solr and lucene -
>
> MultiPhraseQuery throws ArrayIndexOutOfBounds Exception for the words
> defined as synonyms
>
> SEVERE: java.lang.ArrayIndexOutOfBoundsException: 5
>    at
> org.apache.lucene.search.MultiPhraseQuery$MultiPhraseWeight.scorer(MultiPhraseQuery.java:191)
>
>        if (terms.length > 1) {
>          postingsEnum = new UnionDocsAndPositionsEnum(reader, terms);
>
>          // coarse -- this overcounts since a given doc can
>          // have more than one terms:
>          docFreq = 0;
>          for(int j=0;j<terms.length;j++) {
>            // Should be j
>            docFreq += reader.docFreq(terms[*i*]);
>          }
>        } else {
>
> The for loop seems to iterate on terms length with variable j, but refers to
> i within the loop which is iterating on the search terms count.
>
> Regards,
> Jayendra
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org