Friday 4 June 2021

Sitecore solr MaxBytesLengthExceededException issue while index rebuild

While triggering index rebuild from Sitecore control Panel, may get below issue as

SolrNet.Exceptions.SolrConnectionException: <?xml version="1.0" encoding="UTF-8"?>

<response>

<lst name="responseHeader">

<int name="status">400</int><int name="QTime">2147</int></lst><lst name="error">

<lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str>

<str name="root-error-class">org.apache.lucene.util.BytesRefHash$MaxBytesLengthExceededException</str></lst>

<str name="msg">Exception writing document id sitecore://web/{629c0a43-8382-4aa6-10e8-eb2c0fd5460a}?lang=en&amp;ver=2&amp;ndx=YOUR_INDEXNAME

to the index; possible analysis error: Document contains at least one immense term in field="INDEXEDFIELDNAME" (whose UTF8 encoding is longer than the max length 32766),

all of which were skipped.  Please correct the analyzer to not produce such terms.  The prefix of the first immense term is: '[72, 117, 109, 97, 110, 32, 82, 101, 115, 111, 117, 114, 99, 101, 115, 32, 124, 32, 52, 48, 48, 32, 124, 32, 50, 53, 32, 124, 32, 87]...', 

original message: bytes can be at most 32766 in length; got 58214

Perhaps the document has an indexed string field (solr.StrField) which is too large</str><int name="code">400</int></lst>

</response>

 ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.


Possible Fix:

As I tried to highlight useful information from above log and it seems that we are facing size issue for string Field type in solr.

string Field have max size of 32K (32766) and trying to store 58214 char that is why got exception.

one solution is to change fieldType

From the computed Index configuration file, change returnType for indexField as "Text" after removing "String"

This works for me, hope for you as well.

another solution is to bypass index for this particular file. For that there is a setting in config StoreLocation="true" but I do not feel this will be good approach.

No comments:

Post a Comment