Search code examples
elasticsearchtire

elasticsearch highlighting error, failed to highlight ... String index out of range


I cannot make head or tail of this error, and it's 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.

This is a more complete explanation of the problem I'm having, it's exactly the same


Solution

  • As @imotov said above, this is a bug in lucene and therefore elasticsearch, https://issues.apache.org/jira/browse/LUCENE-4899

    You can resolve it by not using the fast vector highlighter, or by setting fragment_size to a higher number to reduce incidences of the bug appearing.

    I doubt that they will go away completely unless you set fragment_size to an impossibly high number, which you could do (in theory, but then you'd have to handle truncation on your own, which kind of defeats the purpose of the highlighter in the first place)