# Error: Document contains at least one immense term in field

**URL:** https://discuss.elastic.co/t/error-document-contains-at-least-one-immense-term-in-field/66486
**Category:** Elasticsearch
**Created:** [November 18, 2016, 7:02am UTC](https://discuss.elastic.co/t/error-document-contains-at-least-one-immense-term-in-field/66486 "2016-11-18T07:02:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)
#### Post date: [November 18, 2016, 7:02am UTC](https://discuss.elastic.co/t/error-document-contains-at-least-one-immense-term-in-field/66486/1 "2016-11-18T07:02:47Z")

</div>

Hi,

I am trying mapping and indexing with ES-5.0.0 and PHP. I did mapping on kibana and I started indexing with my php codes.`(http://192.168.1.35:8080/indexleme.php?p=index)`  
It indexed but then it stopped.  
My error:

```
  Fatal error: Uncaught exception 
    'Elasticsearch\Common\Exceptions\BadRequest400Exception' with message 
    '{"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[NchqMHF][127.0.0.1:9300][indices:data/write/index[p]]"}],"type":"illegal_argument_exception","reason":"Document
     contains at least one immense term in field=\"ParaBirim\" (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: '[32, 75, 71, 32, 72, -60, -80, 68,
     82, 79, 70, -60, -80, 76, 32, 80, 65, 77, 85, 75, 32, 82, 85, 76, 79, 
    32, 49, 48, 48, 48]...', original message: bytes can be at most 32766 in
     length; got 
    35053","caused_by":{"type":"max_bytes_length_exceeded_exception","reason":"bytes
     can be at most 32766 in length; got 35053"}},"status":400}' in 
    /home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:681
    Stack
     trace:
    #0 /home/admin/web/localho in /home/admin/web/localhost.example.com/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 682

```

Problem part of code on mapping:

```
PUT titub3/ihale/_mapping
{
  "properties": {
    "ParaBirim" : {
      "type" : "keyword"
    }
  }
}

```

`ParaBirim` : Values for this field:  
YTL  
TL,  
1.035,00  
..etc

What kind of this mapping should be? keyword or float or others?

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [November 18, 2016, 9:03am UTC](https://discuss.elastic.co/t/error-document-contains-at-least-one-immense-term-in-field/66486/2 "2016-11-18T09:03:12Z")

</div>

Lucene doesn't allow terms that contain more than 32k bytes. You could work around this issue by setting a limit on the length of your keyword fields, eg.

```auto
PUT titub3/ihale/_mapping
{
  "properties": {
    "ParaBirim" : {
      "type" : "keyword",
      "ignore_above": 10000
    }
  }
}

```

This will make Elasticsearch ignore all terms whose UTF8 representation would be more than 10k bytes.

---

<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: [December 16, 2016, 9:03am UTC](https://discuss.elastic.co/t/error-document-contains-at-least-one-immense-term-in-field/66486/3 "2016-12-16T09:03:18Z")

</div>

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