title: ElasticsearchException [Elasticsearch exception [type=max_bytes_length_exceeded_exception, reason=bytes can be at most 32766 in length; got 207707]
body: <p>I am using elasticsearch for log analysis, and some fields have large length: PROCESS_INFO.LOG_INFO.MSG and PROCESS_INFO.SERVICE_INFO.EXCEPTION.</p>
  <p>I mapped those fields with 'keyword' type with ignore_above mapping (ignore_above: 7864320)</p>
  <p>Even after I have set dynamic mapping and new documents were inserted in a new index, exception 'UTF8 encoding is longer than the max length 32766' still exists.</p>
  <p>Any advice, please? Thank you in advance!</p>
  <ul>
  <li>I did not map field PROCESS_INFO.LOG_INFO.MSG with 'text' field, because worried about too much indexing.</li>
  </ul>
  <p><strong>- Error trace:</strong></p>
  <pre><code>ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=Document contains at least one immense term in field=&quot;PROCESS_INFO.LOG_INFO.MSG&quot; (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: '[91, 50, 48, 50, 48, 45, 48, 55, 45, 49, 54, 95, 50, 51, 58, 53, 54, 58, 53, 56, 46, 56, 49, 51, 50, 51, 53, 93, 32, 76]...', original message: bytes can be at most 32766 in length; got 191323]]; nested: ElasticsearchException[Elasticsearch exception [type=max_bytes_length_exceeded_exception, reason=bytes can be at most 32766 in length; got 191323]];
          at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
          at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1721)
          at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1698)
          at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1461)
          at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1418)
          at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1388)
          at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:836)
          at com.lgcns.mom.process.LogServer.insertSingleDocument(LogServer.java:196)
          at com.lgcns.mom.process.LogServer.executeService(LogServer.java:176)
          at com.lgcns.mom.process.QueueServer$1.onReceive(QueueServer.java:93)
          at com.solacesystems.jcsmp.impl.flow.FlowHandleImpl.triggerAsyncDelivery(FlowHandleImpl.java:1534)
  </code></pre>
  <p><strong>GET /_mapping</strong></p>
  <pre><code>{
    &quot;servicerunlogreport-myprogram-2020.07.17&quot; : {
      &quot;mappings&quot; : {
        &quot;dynamic&quot; : &quot;true&quot;,
        &quot;_meta&quot; : { },
        &quot;_source&quot; : {
          &quot;includes&quot; : [ ],
          &quot;excludes&quot; : [ ]
        },
        &quot;dynamic_date_formats&quot; : [
          &quot;strict_date_optional_time&quot;,
          &quot;yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z||yyyy/MM/dd HH:mm:ss.SSS&quot;
        ],
        &quot;dynamic_templates&quot; : [
          {
            &quot;strings_as_keywords&quot; : {
              &quot;match_mapping_type&quot; : &quot;string&quot;,
              &quot;mapping&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              }
            }
          }
        ],
        &quot;date_detection&quot; : true,
        &quot;numeric_detection&quot; : false,
        &quot;properties&quot; : {
          &quot;CMD&quot; : {
            &quot;type&quot; : &quot;keyword&quot;
          },
          &quot;PROCESS_INFO&quot; : {
            &quot;properties&quot; : {
              &quot;LOG_INFO&quot; : {
                &quot;properties&quot; : {
                  &quot;ERR_MSG&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;
                  },
                  &quot;MSG&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;,
                    &quot;ignore_above&quot; : 7864320
                  },
                  &quot;SERVER_TYPE&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;
                  },
                  &quot;SEV&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;
                  },
                  &quot;TXN_KEY&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;
                  },
                  &quot;TXN_NAME&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;
                  },
                  &quot;TXN_TIME&quot; : {
                    &quot;type&quot; : &quot;date&quot;,
                    &quot;format&quot; : &quot;strict_date_optional_time&quot;
                  }
                }
              },
              &quot;PROCESS_ID&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              },
              &quot;PROCESS_TYPE&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              },
              &quot;PROCESS_TYPE_DETAIL&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              },
              &quot;SERVER_ID&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              },
              &quot;SERVICE_INFO&quot; : {
                &quot;properties&quot; : {
                  &quot;EXCEPTION&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;,
                    &quot;ignore_above&quot; : 7864320
                  }
                }
              },
              &quot;SYSTEM_ID&quot; : {
                &quot;type&quot; : &quot;keyword&quot;
              }
            }
          }
        }
      }
    }
  }
  </code></pre>