# StringIndexOutOfBoundsException: String index out of range: -1

**URL:** <https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488>\
**Category:** Elasticsearch\
**Created:** [September 6, 2013, 10:51am UTC](https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488 "2013-09-06T10:51:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![subin](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@subin](https://discuss.elastic.co/u/subin)\
**Post date:** [September 6, 2013, 10:51am UTC](https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488/1 "2013-09-06T10:51:43Z")

</div>

I run ES v 0.90.0. I'm facing 'StringIndexOutOfBoundsException: String  
index out of range: -1 ' only when sending log from a particular server  
through logstash to ES.  
Below is a sample log from that server:

06-Sep-2013 06:10:45.934 transfer of 'domain.ca/IN' from 10.0.4.83#53:  
failed while receiving responses: SERVFAIL

The complete error stack is here: [https://gist.github.com/anonymous/6462292](https://gist.github.com/anonymous/6462292)  
My ES template: [https://gist.github.com/anonymous/6462299](https://gist.github.com/anonymous/6462299)

Any help would be highly appreciated.

Thanks,

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [September 6, 2013, 11:31am UTC](https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488/2 "2013-09-06T11:31:25Z")

</div>

This is a known bug in 0.90.0 which has been fixed:

> <https://github.com/elastic/elasticsearch/issues/2953>
>
> I'm seeing the following in Elastic 0.90.0 during the first attempt attempt to i…nitiate an AnalyzeRequest against a numeric field:
> 
> \`\`\`
> Caused by: java.util.concurrent.ExecutionException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:285)
> at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:272)
> at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:113)
> at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:45)
> ... 38 more
> Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.\<init\>(String.java:207)
> at org.elasticsearch.index.analysis.NumericTokenizer.reset(NumericTokenizer.java:59)
> at org.elasticsearch.index.analysis.NumericTokenizer.reset(NumericTokenizer.java:54)
> at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:202)
> at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:57)
> at org.elasticsearch.action.support.single.custom.TransportSingleCustomOperationAction$AsyncSingleAction$2.run(TransportSingleCustomOperationAction.java:175)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> ... 1 more
> \`\`\`
> 
> The cause of the problem appears to be that the \`reset()\` method of the \`NumericTokenizer\` is called twice the first time \`analyzer.tokenStream()\` is called for a the field in a thread:
> \- The first call happens as a result of Lucene calling \`createComponents()\` on the \`NumericAnalyzer\`. This eventually results in the construction of a \`NumericTokenizer\` with a \`char\[\]\` buffer, which calls \`reset()\` during construction. This first \`reset()\` call leaves the \`FastStringReader\` associated with the Tokenizer with a \`next\` value that is equal to the length of that buffer because it reads all the chars out of the reader.
> \- The second call happens as a result of the explicit call to \`reset()\` in \`TransportAnalyzeAction\` immediately after the \`TokenStream\` has been retrieved from the analyzer. Unfortunately calling the method a second time triggers the \`if (next \>= length)\` check in the \`read()\` method of the associated \`FastStringReader\` to return -1. NumericTokenizer then tries to use -1 as the number of chars to use when constructing a \`String\`, which throws the \`StringIndexOutOfBoundsException\` above.

If you upgrade (I recommend the latests version 0.90.3) this error  
shouldn't occur any more.

On 6 September 2013 12:51, subin [ksubins321@gmail.com](mailto:ksubins321@gmail.com) wrote:

> I run ES v 0.90.0. I'm facing 'StringIndexOutOfBoundsException: String  
> index out of range: -1 ' only when sending log from a particular server  
> through logstash to ES.  
> Below is a sample log from that server:
> 
> 06-Sep-2013 06:10:45.934 transfer of 'domain.ca/IN' from 10.0.4.83#53:  
> failed while receiving responses: SERVFAIL
> 
> The complete error stack is here:  
> [java StringIndexOutOfBoundsException: String index out of range: -1 · GitHub](https://gist.github.com/anonymous/6462292)  
> My ES template: [gist:6462299 · GitHub](https://gist.github.com/anonymous/6462299)
> 
> Any help would be highly appreciated.
> 
> Thanks,
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![subin](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@subin](https://discuss.elastic.co/u/subin)\
**Post date:** [September 24, 2013, 5:56pm UTC](https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488/3 "2013-09-24T17:56:20Z")

</div>

I've upgraded and ithas got fixed.

Thanks a lot.

On Friday 06 September 2013 05:01 PM, Martijn v Groningen wrote:

> This is a known bug in 0.90.0 which has been fixed:  
> [TransportAnalyzeAction causes StringIndexOutOfBoundsException on first attempt to analyze a numeric field · Issue #2953 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2953)
> 
> If you upgrade (I recommend the latests version 0.90.3) this error  
> shouldn't occur any more.
> 
> On 6 September 2013 12:51, subin \<[ksubins321@gmail.com](mailto:ksubins321@gmail.com)  
> [mailto:ksubins321@gmail.com](mailto:ksubins321@gmail.com)\> wrote:
> 
> ```
> I run ES v 0.90.0. I'm facing 'StringIndexOutOfBoundsException:
> String index out of range: -1 ' only when sending log from a
> particular server through logstash to ES.
> Below is a sample log from that server:
> 
> 06-Sep-2013 06:10:45.934 transfer of 'domain.ca/IN
> <http://domain.ca/IN>' from 10.0.4.83#53: failed while receiving
> responses: SERVFAIL
> 
> The complete error stack is here:
> https://gist.github.com/anonymous/6462292
> My ES template: https://gist.github.com/anonymous/6462299
> 
> Any help would be highly appreciated.
> 
> Thanks,
> -- 
> You received this message because you are subscribed to the Google
> Groups "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to elasticsearch+unsubscribe@googlegroups.com
> <mailto:elasticsearch%2Bunsubscribe@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> ```
> 
> --  
> Met vriendelijke groet,
> 
> ## Martijn van Groningen
> 
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/iRKLe38hxys/unsubscribe](https://groups.google.com/d/topic/elasticsearch/iRKLe38hxys/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Subin

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:14am UTC](https://discuss.elastic.co/t/stringindexoutofboundsexception-string-index-out-of-range-1/13488/4 "2017-07-06T02:14:51Z")

</div>


