You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Gérard Dupont <ge...@gmail.com> on 2010/08/27 18:16:10 UTC

DocSlide.DocIterator.nextDoc()

Hi all,

I recently came across a strange exception while using SolR. In fact I have
an ArrayOutOfBoundsException while using the server and making "normal"
query (I mean not different from before). The trace is he following :

Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
at org.apache.solr.search.DocSlice$1.nextDoc(DocSlice.java:117)
at
org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:273)
 at
org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:89)
at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
 at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
 at
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:139)
... 37 more

It seems to be linked to the highlighting module but as I had a look on the
code I think I could understand why it fails :

      public int nextDoc() {
        return docs[pos++];
      }

So my basic reading tells me that one may eventually come in a case where
the system will do one too much "++" ;-) . Iguess one should prevent this
call checking the "hasNext()" but it not done everywhere apparently so I
suggest just to implement it in the nextDoc() it self...

What do you think ? Any one faced this problem yet ?

-- 
Gérard Dupont
Information Processing Control and Cognition (IPCC) - EADS DS
http://weblab.ow2.org

Document & Learning team - LITIS Laboratory

Re: DocSlide.DocIterator.nextDoc()

Posted by Lance Norskog <go...@gmail.com>.
There are edge cases in Highlighting and what some Analyzers generate.
Look for those on the JIRA.

On Fri, Aug 27, 2010 at 5:46 PM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> 2010/8/27 Gérard Dupont <ge...@gmail.com>:
>> Hi all,
>> I recently came across a strange exception while using SolR. In fact I have
>> an ArrayOutOfBoundsException while using the server and making "normal"
>> query (I mean not different from before). The trace is he following :
>> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
>> at org.apache.solr.search.DocSlice$1.nextDoc(DocSlice.java:117)
>> at
>> org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:273)
>> at
>> org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:89)
>> at
>> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
>> at
>> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
>> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
>> at
>> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:139)
>> ... 37 more
>> It seems to be linked to the highlighting module but as I had a look on the
>> code I think I could understand why it fails :
>>       public int nextDoc() {
>>         return docs[pos++];
>>       }
>> So my basic reading tells me that one may eventually come in a case where
>> the system will do one too much "++" ;-) . Iguess one should prevent this
>> call checking the "hasNext()" but it not done everywhere apparently so I
>> suggest just to implement it in the nextDoc() it self...
>> What do you think ? Any one faced this problem yet ?
>
> nextDoc() may be called millions of times for a single request (during
> faceting), so we shouldn't add extra logic to it.  And even if we
> could... what would we do?  If we return a bogus number, that just
> pushes the error somewhere else.  We should fix the root cause of the
> problem.
>
> What version if Solr are you using?
> A quick look at trunk tells me there is only one call to nextDoc() in
> DefaultSolrHighlighter, and it looks fine:
>
>    DocIterator iterator = docs.iterator();
>    for (int i = 0; i < docs.size(); i++) {
>      int docId = iterator.nextDoc();
>
> It doesn't check hasNext(), but it does check the size, so it should be fine.
>
> -Yonik
> http://www.lucidimagination.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>



-- 
Lance Norskog
goksron@gmail.com

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


Re: DocSlide.DocIterator.nextDoc()

Posted by Yonik Seeley <yo...@lucidimagination.com>.
2010/8/27 Gérard Dupont <ge...@gmail.com>:
> Hi all,
> I recently came across a strange exception while using SolR. In fact I have
> an ArrayOutOfBoundsException while using the server and making "normal"
> query (I mean not different from before). The trace is he following :
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at org.apache.solr.search.DocSlice$1.nextDoc(DocSlice.java:117)
> at
> org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:273)
> at
> org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:89)
> at
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
> at
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
> at
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:139)
> ... 37 more
> It seems to be linked to the highlighting module but as I had a look on the
> code I think I could understand why it fails :
>       public int nextDoc() {
>         return docs[pos++];
>       }
> So my basic reading tells me that one may eventually come in a case where
> the system will do one too much "++" ;-) . Iguess one should prevent this
> call checking the "hasNext()" but it not done everywhere apparently so I
> suggest just to implement it in the nextDoc() it self...
> What do you think ? Any one faced this problem yet ?

nextDoc() may be called millions of times for a single request (during
faceting), so we shouldn't add extra logic to it.  And even if we
could... what would we do?  If we return a bogus number, that just
pushes the error somewhere else.  We should fix the root cause of the
problem.

What version if Solr are you using?
A quick look at trunk tells me there is only one call to nextDoc() in
DefaultSolrHighlighter, and it looks fine:

    DocIterator iterator = docs.iterator();
    for (int i = 0; i < docs.size(); i++) {
      int docId = iterator.nextDoc();

It doesn't check hasNext(), but it does check the size, so it should be fine.

-Yonik
http://www.lucidimagination.com

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