# Ingest attachement plugin not able index complex pdf

**URL:** <https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810>\
**Category:** Elasticsearch\
**Created:** [September 25, 2018, 11:23am UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810 "2018-09-25T11:23:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakhansamani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lakhansamani/32/35851_2.png) [@lakhansamani](https://discuss.elastic.co/u/lakhansamani)\
**Post date:** [September 25, 2018, 11:23am UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/1 "2018-09-25T11:23:12Z")

</div>

I am trying to index following file pdf but it fails.  
[https://drive.google.com/open?id=1KS\_ow1mfQKLjv\_9zihpkn-No1vq0Z\_a7](https://drive.google.com/open?id=1KS_ow1mfQKLjv_9zihpkn-No1vq0Z_a7)

```auto

axios.put(`${ELASTIC_SEARCH_DOC_URL}/_ingest/pipeline/${id}`, {
        "description" : "Extract attachment information",
        "processors" : [
          {
            "attachment" : {
              "field" : "data",
              "indexed_chars": -1,
              "ignore_failure": true,
            }
          }
        ]
      }, {
        headers: {
          "Content-Type": "application/json"
        }
      }).then(() => {

        const url = `${ELASTIC_SEARCH_DOC_URL}/${ELASTIC_SEARCH_DOC_INDEX}/documents/${id}?pipeline=${id}`
        const data = {
          data: base64Encode(file),
          link: f.link,
          tranId: f.tranId,
          ...f.indexingTags,
        }

        axios.put(url, data, {
          headers: {
            "Content-Type": "application/json"
          }
        }).then((iData) => {
          indexedFiles.push(f)
          resolve(iData)
        }).catch(err => {
          fs.appendFileSync(errorFileLogs, `Attachment Pilpeline Failed => ${url}\n${err}\n\n`)
          resolve()
        })
      }).catch(err => {
        console.log(err)
        fs.appendFileSync(errorFileLogs, `Ingest Pilpeline Failed => \n${err}\n`)
        resolve()
      })

```

I was able to successfully index a simple pdf: [http://www.africau.edu/images/default/sample.pdf](http://www.africau.edu/images/default/sample.pdf)

Can some one guide how can I fix the above issue

Thanks

---

<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:** [September 25, 2018, 12:58pm UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/2 "2018-09-25T12:58:52Z")

</div>

What is the error? What are the logs?

---

<div class="post-metadata">

**Author:** ![lakhansamani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lakhansamani/32/35851_2.png) [@lakhansamani](https://discuss.elastic.co/u/lakhansamani)\
**Post date:** [September 25, 2018, 1:50pm UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/3 "2018-09-25T13:50:29Z")

</div>

It is throwing 400 error in http request, exact error message is  
`Error: Request failed with status code 400`

---

<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:** [September 25, 2018, 2:35pm UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/4 "2018-09-25T14:35:21Z")

</div>

You probably have other details. Look at the logs.  
Otherwise try to reproduce with Kibana console or curl.

---

<div class="post-metadata">

**Author:** ![lakhansamani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lakhansamani/32/35851_2.png) [@lakhansamani](https://discuss.elastic.co/u/lakhansamani)\
**Post date:** [September 25, 2018, 4:31pm UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/5 "2018-09-25T16:31:25Z")

</div>

Thanks @dadoonet, just found following error

```auto

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Document contains at least one immense term in field=\"data.raw\" (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: '[74, 86, 66, 69, 82, 105, 48, 120, 76, 106, 81, 75, 74, 89, 67, 65, 103, 73, 65, 75, 77, 83, 65, 119, 73, 71, 57, 105, 97, 103]...', original message: bytes can be at most 32766 in length; got 183560"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Document contains at least one immense term in field=\"data.raw\" (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: '[74, 86, 66, 69, 82, 105, 48, 120, 76, 106, 81, 75, 74, 89, 67, 65, 103, 73, 65, 75, 77, 83, 65, 119, 73, 71, 57, 105, 97, 103]...', original message: bytes can be at most 32766 in length; got 183560",
        "caused_by": {
            "type": "max_bytes_length_exceeded_exception",
            "reason": "bytes can be at most 32766 in length; got 183560"
        }
    },
    "status": 400
}

```

---

<div class="post-metadata">

**Author:** ![lakhansamani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lakhansamani/32/35851_2.png) [@lakhansamani](https://discuss.elastic.co/u/lakhansamani)\
**Post date:** [September 26, 2018, 6:08am UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/6 "2018-09-26T06:08:01Z")

</div>

@dadoonet issue is fixed, I was indexing `base64` encoded field also which was quite large

Thanks for the support

---

<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:** [October 24, 2018, 6:08am UTC](https://discuss.elastic.co/t/ingest-attachement-plugin-not-able-index-complex-pdf/149810/7 "2018-10-24T06:08:03Z")

</div>

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