You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jerry Li <zo...@gmail.com> on 2010/12/01 06:26:32 UTC

ArrayIndexOutOfBoundsException in sort

Hi team

My solr version is 1.4
There is an ArrayIndexOutOfBoundsException when i sort one field and the
following is my code and log info,
any help will be appreciated.

Code:

        SolrQuery query = new SolrQuery();
        query.setSortField("author", ORDER.desc);
        query.addFilterQuery("pubType:2");

        query.setQuery("*:*");
        query.setStart(0);
        query.setRows(10);
        QueryResponse rsp = getHttpSolrServer().query(query);
(BTW, there will be Chinese Charactors in *author *field)

Log info :

Dec 1, 2010 1:05:12 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.ArrayIndexOutOfBoundsException: 2
        at
org.apache.lucene.search.FieldCacheImpl$StringIndexCache.createValue(FieldCacheImpl.java:721)
        at
org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:224)
        at
org.apache.lucene.search.FieldCacheImpl.getStringIndex(FieldCacheImpl.java:692)
        at
org.apache.lucene.search.FieldComparator$StringOrdValComparator.setNextReader(FieldComparator.java:667)
        at
org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:94)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:257)
        at org.apache.lucene.search.Searcher.search(Searcher.java:171)
        at
org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:988)
        at
org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:884)
        at
org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:341)
        at
org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:182)
        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.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338)
        at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)

Dec 1, 2010 1:05:12 PM org.apache.solr.core.SolrCore execute
INFO: [] webapp=/solr path=/select
params={sort=author+desc&start=0&q=folderId:1+2+10001+&wt=javabin&fq=pubType:2&rows=100&version=1}
status=500 QTime=4
Dec 1, 2010 1:05:12 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.ArrayIndexOutOfBoundsException: 2
        at
org.apache.lucene.search.FieldCacheImpl$StringIndexCache.createValue(FieldCacheImpl.java:721)
        at
org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:224)
        at
org.apache.lucene.search.FieldCacheImpl.getStringIndex(FieldCacheImpl.java:692)
        at
org.apache.lucene.search.FieldComparator$StringOrdValComparator.setNextReader(FieldComparator.java:667)
        at
org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:94)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:257)
        at org.apache.lucene.search.Searcher.search(Searcher.java:171)
        at
org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:988)
        at
org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:884)
        at
org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:341)
        at
org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:182)
        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.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338)
        at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)


-- 

Best Regards.
Jerry. Li | 李宗杰


Re: ArrayIndexOutOfBoundsException in sort

Posted by Jerry Li <zo...@gmail.com>.
Got it with thanks.

On Wed, Dec 1, 2010 at 8:02 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> > It seems work fine again after I change "author" field type
> > from text to
> > string, could anybody give some info about it? very
> > appriciated.
>
>
> http://wiki.apache.org/solr/FAQ#Why_Isn.27t_Sorting_Working_on_my_Text_Fields.3F
>
> And also see Erick's explanation
>
> http://search-lucene.com/m/7fnj1TtNde/sort+on+a+tokenized+field&subj=Re+Solr+sorting+problem
>
>
>
>


-- 

Best Regards.
Jerry. Li


Re: ArrayIndexOutOfBoundsException in sort

Posted by Ahmet Arslan <io...@yahoo.com>.
> It seems work fine again after I change "author" field type
> from text to
> string, could anybody give some info about it? very
> appriciated.

http://wiki.apache.org/solr/FAQ#Why_Isn.27t_Sorting_Working_on_my_Text_Fields.3F

And also see Erick's explanation 
http://search-lucene.com/m/7fnj1TtNde/sort+on+a+tokenized+field&subj=Re+Solr+sorting+problem


      

Re: ArrayIndexOutOfBoundsException in sort

Posted by Jerry Li <zo...@gmail.com>.
Hi

It seems work fine again after I change "author" field type from text to
string, could anybody give some info about it? very appriciated.

<field name="author" type="string" indexed="true" stored="true"
required="true" default=" "/>


On Wed, Dec 1, 2010 at 5:20 PM, Jerry Li <zo...@gmail.com> wrote:

> sorry for lost, following is my schema.xml config and I use IKTokenizer for
> Chinese charactor
>
>
>
>    <fieldType name="text" class="solr.TextField"
> positionIncrementGap="100">
>       <analyzer type="index">
>         <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"
> isMaxWordLength="false"/>
>         <!-- tokenizer class="solr.WhitespaceTokenizerFactory"/ -->
>         <!-- in this example, we will only use synonyms at query time
>         <filter class="solr.SynonymFilterFactory"
> synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
>         -->
>         <!-- Case insensitive stop word removal.
>           add enablePositionIncrements=true in both the index and query
>           analyzers to leave a 'gap' for more accurate phrase queries.
>         -->
>         <filter class="solr.StopFilterFactory"
>                 ignoreCase="true"
>                 words="stopwords.txt"
>                 enablePositionIncrements="true"
>                 />
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumb
> ers="1" catenateAll="0" splitOnCaseChange="1"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.SnowballPorterFilterFactory" language="English"
> protected="protwords.txt"/>
>       </analyzer>
>       <analyzer type="query">
>         <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"
> isMaxWordLength="true"/>
>         <!-- tokenizer class="solr.WhitespaceTokenizerFactory"/ -->
>         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
>         <filter class="solr.StopFilterFactory"
>                 ignoreCase="true"
>                 words="stopwords.txt"
>                 enablePositionIncrements="true"
>                 />
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumb
> ers="0" catenateAll="0" splitOnCaseChange="1"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.SnowballPorterFilterFactory" language="English"
> protected="protwords.txt"/>
>       </analyzer>
>     </fieldType>
>
>
>    <field name="id" type="string" indexed="true" stored="true"
> required="true" />
>    <field name="documentId" type="tlong" indexed="true" stored="true"
> required="true" />
>    <field name="headline" type="text" indexed="true" stored="true"
> omitNorms="true" required="true" />
>    <field name="content" type="text" indexed="true" stored="true"
> compressed="true" omitNorms="true" required="true" />
>    <field name="author" type="text" indexed="true" stored="true"
> required="true" default=" "/>
>    <field name="pubName" type="text" indexed="true" stored="true"
> required="true" default=" "/>
>    <field name="pubType" type="tint" indexed="true" stored="true"
> required="true" />
>    <field name="section" type="text" indexed="true" stored="true"
> required="true" />
>    <field name="column" type="text" indexed="true" stored="true"
> required="true" />
>    <field name="folderId" type="tint" indexed="true" stored="true"
> required="true"/>
>    <field name="userId" type="string" indexed="true" stored="true"
> required="true"/>
>    <field name="readType" type="tint" indexed="true" stored="true"
> required="true" />
>    <field name="downloadType" type="tint" indexed="true" stored="true"
> required="true" />
>    <field name="hasImg" type="tint" indexed="false" stored="true"
> required="true" />
>    <field name="hasText" type="tint" indexed="false" stored="true"
> required="true" />
>    <field name="pubDate" type="tint" indexed="true" stored="true"
> required="true"/>
>    <field name="trackingTime" type="tint" indexed="true" stored="true"
> required="true" />
>    <field name="text" type="text" indexed="true" stored="false"
> multiValued="true"/>
>
>
> <uniqueKey>id</uniqueKey>
>
> <defaultSearchField>text</defaultSearchField>
>
>    <copyField source="headline" dest="text"/>
>    <copyField source="content" dest="text"/>
>
>
>
> On Wed, Dec 1, 2010 at 2:50 PM, Gora Mohanty <go...@mimirtech.com> wrote:
>
>> On Wed, Dec 1, 2010 at 10:56 AM, Jerry Li <zo...@gmail.com> wrote:
>> > Hi team
>> >
>> > My solr version is 1.4
>> > There is an ArrayIndexOutOfBoundsException when i sort one field and the
>> > following is my code and log info,
>> > any help will be appreciated.
>> >
>> > Code:
>> >
>> >        SolrQuery query = new SolrQuery();
>> >        query.setSortField("author", ORDER.desc);
>> [...]
>>
>> Please show us how the field "author" defined in your
>> schema.xml. Sorting has to be done on a non-tokenized
>> field, e.g., a StrField.
>>
>> Regards,
>> Gora
>>
>
>
>
> --
>
> Best Regards.
> Jerry. Li | 李宗杰
> 
>



-- 

Best Regards.
Jerry. Li | 李宗杰


Re: ArrayIndexOutOfBoundsException in sort

Posted by Jerry Li <zo...@gmail.com>.
sorry for lost, following is my schema.xml config and I use IKTokenizer for
Chinese charactor



   <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"
isMaxWordLength="false"/>
        <!-- tokenizer class="solr.WhitespaceTokenizerFactory"/ -->
        <!-- in this example, we will only use synonyms at query time
        <filter class="solr.SynonymFilterFactory"
synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
        -->
        <!-- Case insensitive stop word removal.
          add enablePositionIncrements=true in both the index and query
          analyzers to leave a 'gap' for more accurate phrase queries.
        -->
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                enablePositionIncrements="true"
                />
        <filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumb
ers="1" catenateAll="0" splitOnCaseChange="1"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="English"
protected="protwords.txt"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory"
isMaxWordLength="true"/>
        <!-- tokenizer class="solr.WhitespaceTokenizerFactory"/ -->
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords.txt"
                enablePositionIncrements="true"
                />
        <filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumb
ers="0" catenateAll="0" splitOnCaseChange="1"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="English"
protected="protwords.txt"/>
      </analyzer>
    </fieldType>


   <field name="id" type="string" indexed="true" stored="true"
required="true" />
   <field name="documentId" type="tlong" indexed="true" stored="true"
required="true" />
   <field name="headline" type="text" indexed="true" stored="true"
omitNorms="true" required="true" />
   <field name="content" type="text" indexed="true" stored="true"
compressed="true" omitNorms="true" required="true" />
   <field name="author" type="text" indexed="true" stored="true"
required="true" default=" "/>
   <field name="pubName" type="text" indexed="true" stored="true"
required="true" default=" "/>
   <field name="pubType" type="tint" indexed="true" stored="true"
required="true" />
   <field name="section" type="text" indexed="true" stored="true"
required="true" />
   <field name="column" type="text" indexed="true" stored="true"
required="true" />
   <field name="folderId" type="tint" indexed="true" stored="true"
required="true"/>
   <field name="userId" type="string" indexed="true" stored="true"
required="true"/>
   <field name="readType" type="tint" indexed="true" stored="true"
required="true" />
   <field name="downloadType" type="tint" indexed="true" stored="true"
required="true" />
   <field name="hasImg" type="tint" indexed="false" stored="true"
required="true" />
   <field name="hasText" type="tint" indexed="false" stored="true"
required="true" />
   <field name="pubDate" type="tint" indexed="true" stored="true"
required="true"/>
   <field name="trackingTime" type="tint" indexed="true" stored="true"
required="true" />
   <field name="text" type="text" indexed="true" stored="false"
multiValued="true"/>


<uniqueKey>id</uniqueKey>

<defaultSearchField>text</defaultSearchField>

   <copyField source="headline" dest="text"/>
   <copyField source="content" dest="text"/>


On Wed, Dec 1, 2010 at 2:50 PM, Gora Mohanty <go...@mimirtech.com> wrote:

> On Wed, Dec 1, 2010 at 10:56 AM, Jerry Li <zo...@gmail.com> wrote:
> > Hi team
> >
> > My solr version is 1.4
> > There is an ArrayIndexOutOfBoundsException when i sort one field and the
> > following is my code and log info,
> > any help will be appreciated.
> >
> > Code:
> >
> >        SolrQuery query = new SolrQuery();
> >        query.setSortField("author", ORDER.desc);
> [...]
>
> Please show us how the field "author" defined in your
> schema.xml. Sorting has to be done on a non-tokenized
> field, e.g., a StrField.
>
> Regards,
> Gora
>



-- 

Best Regards.
Jerry. Li | 李宗杰


Re: ArrayIndexOutOfBoundsException in sort

Posted by Gora Mohanty <go...@mimirtech.com>.
On Wed, Dec 1, 2010 at 10:56 AM, Jerry Li <zo...@gmail.com> wrote:
> Hi team
>
> My solr version is 1.4
> There is an ArrayIndexOutOfBoundsException when i sort one field and the
> following is my code and log info,
> any help will be appreciated.
>
> Code:
>
>        SolrQuery query = new SolrQuery();
>        query.setSortField("author", ORDER.desc);
[...]

Please show us how the field "author" defined in your
schema.xml. Sorting has to be done on a non-tokenized
field, e.g., a StrField.

Regards,
Gora