# Weird highlighting error ... failed to highlight field ... String index out of range

**URL:** <https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394>\
**Category:** Elasticsearch\
**Created:** [April 1, 2013, 6:07am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394 "2013-04-01T06:07:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 1, 2013, 6:07am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/1 "2013-04-01T06:07:32Z")

</div>

I cannot make head or tail of this error, and its happening pretty randomly  
to where I don't even know where to start looking.

This is what the full error looks like

Tire::Search::SearchRequestFailed: 500 :  
{"error":"SearchPhaseExecutionException[Failed to execute phase  
[query\_fetch], total failure; shardFailures  
{[7McitJnjQkqLkViqUpZUyw][content][4]:  
FetchPhaseExecutionException[[content][4]: query[+\_all:account +\_all:set  
+\_all:up],from[0],size[20]: Fetch Failed [Failed to highlight field  
[post\_content]]]; nested: StringIndexOutOfBoundsException[String index out  
of range: -5]; }]","status":500}

A query like  
"relationship learning"  
will run fine, but running  
"relationship centered learning"  
will throw the error, actually any of these letters c, d, j, q, x, z used  
with "relationship learning" .. like "d relationship learning" will throw  
the error.

Its truly maddening.

I'm running elasticsearch 19.2 with Tire  
I just want to know where to start looking, any ideas will help.

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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [April 1, 2013, 9:19am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/2 "2013-04-01T09:19:00Z")

</div>

can you see any errors in the log files that give more information about  
what happens here? or can you make this reproducible with a selfcontained  
gist?

simon

On Monday, April 1, 2013 8:07:32 AM UTC+2, concept47 wrote:

> I cannot make head or tail of this error, and its happening pretty  
> randomly to where I don't even know where to start looking.
> 
> This is what the full error looks like
> 
> Tire::Search::SearchRequestFailed: 500 :  
> {"error":"SearchPhaseExecutionException[Failed to execute phase  
> [query\_fetch], total failure; shardFailures  
> {[7McitJnjQkqLkViqUpZUyw][content][4]:  
> FetchPhaseExecutionException[[content][4]: query[+\_all:account +\_all:set  
> +\_all:up],from[0],size[20]: Fetch Failed [Failed to highlight field  
> [post\_content]]]; nested: StringIndexOutOfBoundsException[String index out  
> of range: -5]; }]","status":500}
> 
> A query like  
> "relationship learning"  
> will run fine, but running  
> "relationship centered learning"  
> will throw the error, actually any of these letters c, d, j, q, x, z used  
> with "relationship learning" .. like "d relationship learning" will throw  
> the error.
> 
> Its truly maddening.
> 
> I'm running elasticsearch 19.2 with Tire  
> I just want to know where to start looking, any ideas will help.
> 
> 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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 1, 2013, 4:48pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/3 "2013-04-01T16:48:40Z")

</div>

Its too random to reproduce, and I'm trying to track down what could be  
wrong.  
The error occurs on random queries, but once those queries error out, they  
_always_ error out.

Nothing in Elasticsearch logs. In fact this is all thats in there.

[2013-04-01 05:20:37,638][INFO][org.elasticsearch.node] [Arclight]  
{0.19.2}[30832]: initializing ...  
[2013-04-01 05:20:37,758][INFO][org.elasticsearch.plugins] [Arclight]  
loaded , sites [mapper-attachments, cloud-aws]  
[2013-04-01 05:20:41,208][INFO][org.elasticsearch.node] [Arclight]  
{0.19.2}[30832]: initialized  
[2013-04-01 05:20:41,208][INFO][org.elasticsearch.node] [Arclight]  
{0.19.2}[30832]: starting ...  
[2013-04-01 05:20:41,309][INFO][org.elasticsearch.transport] [Arclight]  
bound\_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish\_address  
{inet[/10.0.92.233:9300]}  
[2013-04-01 05:20:44,367][INFO][org.elasticsearch.cluster.service]  
[Arclight] new\_master  
[Arclight][Hc-s8CDOSuq6iN21XM0TAg][inet[/10.0.92.233:9300]], reason:  
zen-disco-join (elected\_as\_master)  
[2013-04-01 05:20:44,425][INFO][org.elasticsearch.discovery] [Arclight]  
elasticsearch-production/Hc-s8CDOSuq6iN21XM0TAg  
[2013-04-01 05:20:44,453][INFO][org.elasticsearch.http] [Arclight]  
bound\_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish\_address  
{inet[/10.0.92.233:9200]}  
[2013-04-01 05:20:44,453][INFO][org.elasticsearch.node] [Arclight]  
{0.19.2}[30832]: started  
[2013-04-01 05:20:47,454][INFO][org.elasticsearch.gateway] [Arclight]  
recovered [3] indices into cluster\_state

On Monday, April 1, 2013 4:19:00 AM UTC-5, simonw wrote:

> can you see any errors in the log files that give more information about  
> what happens here? or can you make this reproducible with a selfcontained  
> gist?
> 
> simon

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 1, 2013, 6:23pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/4 "2013-04-01T18:23:52Z")

</div>

Here's a gist of a guy wwho was having the same exact problem, complete  
with an elasticsearch stack trace

> <https://gist.github.com/lukas-vlcek/5005428>

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 1, 2013, 10:50pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/5 "2013-04-01T22:50:28Z")

</div>

Here's my stack trace (finally figured out how to get it)

> <https://gist.github.com/ike-bloomfire/058639517390762fb389>

  
thanks for the help

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [April 3, 2013, 9:27am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/6 "2013-04-03T09:27:00Z")

</div>

this seems to be a Lucene issue, I have a lucene testcase that reproduces  
this problem. it seems to be caused by  
this: [[LUCENE-4899] FastVectorHighlihgter fails with SIOOB if single phrase or term is \> fragCharSize - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4899)

can you raise frag size to see if it goes away?

simon  
On Tuesday, April 2, 2013 12:50:28 AM UTC+2, concept47 wrote:

> Here's my stack trace (finally figured out how to get it)  
> [stack trace of elasticsearch highlighting error/bug · GitHub](https://gist.github.com/ike-bloomfire/058639517390762fb389)  
> thanks for the help

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 3, 2013, 10:02pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/7 "2013-04-03T22:02:09Z")

</div>

We can't, because specific ux interactions in our app depend on that  
particular restriction.  
What we will do drop the use of fast vector highlighter, then watch that  
lucene ticket to see when it gets resolved and eventually makes its way  
into elasticsearch, before turning it back on.

thank you so very much for all your help Simon.  
This was driving me _absolutely_ crazy.

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 4, 2013, 5:13am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/8 "2013-04-04T05:13:40Z")

</div>

Another question, where can I report this bug?

> <https://stackoverflow.com/questions/13750330/elasticsearch-highlighting-on-ngram-filter-is-weird-if-min-gram-is-set-to-1/15005321#15005321>

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [April 5, 2013, 6:36pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/9 "2013-04-05T18:36:43Z")

</div>

hey,

so I can try to put this into a lucene test but I guess this is rather an  
ngram issue than a highlighter issue.  
Can you open an issue on github (elasticsearch) and I take it from there?

simon

On Thursday, April 4, 2013 7:13:40 AM UTC+2, concept47 wrote:

> Another question, where can I report this bug?
> 
> [Elasticsearch highlighting on ngram filter is weird if min\_gram is set to 1 - Stack Overflow](http://stackoverflow.com/questions/13750330/elasticsearch-highlighting-on-ngram-filter-is-weird-if-min-gram-is-set-to-1/15005321#15005321)

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 5, 2013, 7:12pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/10 "2013-04-05T19:12:01Z")

</div>

Done. [https://github.com/elasticsearch/elasticsearch/issues/2839](https://github.com/elasticsearch/elasticsearch/issues/2839)  
Thank you!

Ike

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [April 9, 2013, 10:33pm UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/11 "2013-04-09T22:33:26Z")

</div>

Hey Simon,  
I just discovered that term\_vector takes the following as arguments, yes,  
with\_offsets, with\_positions in addition to with\_position\_offsets.  
Could using one of the other arguments (not with\_positions\_offsets) avoid  
this exceptions?

On Wednesday, April 3, 2013 4:27:00 AM UTC-5, simonw wrote:

> this seems to be a Lucene issue, I have a lucene testcase that reproduces  
> this problem. it seems to be caused by this:  
> [[LUCENE-4899] FastVectorHighlihgter fails with SIOOB if single phrase or term is \> fragCharSize - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4899)
> 
> can you raise frag size to see if it goes away?
> 
> >

--  
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:** ![concept47](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@concept47](https://discuss.elastic.co/u/concept47)\
**Post date:** [May 1, 2013, 9:27am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/12 "2013-05-01T09:27:52Z")

</div>

Hi Simon.  
It seems you got this fixed in  
Lucene. [[LUCENE-4899] FastVectorHighlihgter fails with SIOOB if single phrase or term is \> fragCharSize - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4899)  
Any idea when it will go into Elasticsearch?

On Wednesday, April 3, 2013 2:27:00 AM UTC-7, simonw wrote:

> this seems to be a Lucene issue, I have a lucene testcase that reproduces  
> this problem. it seems to be caused by this:  
> [[LUCENE-4899] FastVectorHighlihgter fails with SIOOB if single phrase or term is \> fragCharSize - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-4899)
> 
> can you raise frag size to see if it goes away?
> 
> simon  
> On Tuesday, April 2, 2013 12:50:28 AM UTC+2, concept47 wrote:
> 
> > Here's my stack trace (finally figured out how to get it)  
> > [stack trace of elasticsearch highlighting error/bug · GitHub](https://gist.github.com/ike-bloomfire/058639517390762fb389)  
> > thanks for the help

--  
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:38am UTC](https://discuss.elastic.co/t/weird-highlighting-error-failed-to-highlight-field-string-index-out-of-range/11394/13 "2017-07-06T02:38:52Z")

</div>


