# Max length of a field exceeded error

**URL:** <https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894>\
**Category:** Elasticsearch\
**Created:** [June 3, 2019, 6:51am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894 "2019-06-03T06:51:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 3, 2019, 6:51am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/1 "2019-06-03T06:51:32Z")

</div>

Hi,

I'm on elasticsearch 7.0.0, And been getting the error in elasticsearch logs like below:

```
org.elasticsearch.transport.RemoteTransportException: [host][ip:9300][indices:data/read/search[phase/fetch/id]]
Caused by: java.lang.IllegalArgumentException: The length of [index.keyword] field of [some_doc] doc of [index] index has exceeded [1000000] - maximum allowed to be analyzed for highlighting. This maximum can be set by changing the [index.highlight.max_analyzed_offset] index level setting. For large texts, indexing with offsets or term vectors is recommended!
        at org.elasticsearch.search.fetch.subphase.highlight.UnifiedHighlighter.highlight(UnifiedHighlighter.java:88) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.search.fetch.subphase.highlight.HighlightPhase.hitExecute(HighlightPhase.java:107) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:169) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.search.SearchService.lambda$executeFetchPhase$3(SearchService.java:540) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:380) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) ~[elasticsearch-7.0.0.jar:7.0.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-7.0.0.jar:7.0.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.lang.Thread.run(Thread.java:835) [?:?]

```

I used term\_vector for some large fields as suggested in the error message above. But it increases the index size (with\_positions\_offsets). And also after fixing few large fields, i started getting error for other fields whose values are large in only very few documents, but in most documents they are very small. (Is it okay to define those fields as term\_vectors too?)

Seems like this error occurs for only [index.keyword] fields, which are i suppose used for aggregation.

So, looking at the error it seems like there are two ways to solve this problem.

1. Disable highlighting on those indices. (Assuming the problem occurs only during highlighting).
2. Disable aggregation on large fields. (Assuming the problem is only with .keyword fields)

Can you please suggest which is the right approach in this case?

---

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 3, 2019, 7:14am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/2 "2019-06-03T07:14:03Z")

</div>

Anyone? thoughts?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 3, 2019, 7:15am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/3 "2019-06-03T07:15:17Z")

</div>

Please do not ping people not already involved in the thread. This forum is manned by volunteers so you need to be patient.

---

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 3, 2019, 7:18am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/4 "2019-06-03T07:18:48Z")

</div>

Apologies!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 3, 2019, 9:52am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/5 "2019-06-03T09:52:28Z")

</div>

Adding this to Christian's answer:

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 3, 2019, 10:56am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/6 "2019-06-03T10:56:10Z")

</div>

Yeah, thanks for the pointer. I'll try to follow that.

---

<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 1, 2019, 10:56am UTC](https://discuss.elastic.co/t/max-length-of-a-field-exceeded-error/183894/7 "2019-07-01T10:56:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
