# How to use elasticsearch 8.x ingest-attachment with Python

**URL:** https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286
**Category:** Elasticsearch
**Tags:** ingest-pipeline
**Created:** [January 17, 2023, 4:03am UTC](https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286 "2023-01-17T04:03:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![garami](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@garami](https://discuss.elastic.co/u/garami)
#### Post date: [January 17, 2023, 4:03am UTC](https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286/1 "2023-01-17T04:03:26Z")

</div>

I am trying to read a pdf from python and send it to elasticsearch. I tried to use ingest-attachment to help with that, but I don't know how.

> **[Attachment processor | Elasticsearch Guide \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/master/attachment.html)**

When I followed the official documentation, it worked. However, there doesn't seem to be a way to use Python in the official documentation.

so, I looked at the official documentation and created my own mapping

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bd110b236769693854545f8cd3c082a58bc91446.png)

Data is entered but not attached.

Wandered around and found this. but i don't know how to use

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/9/89fe1a1fb4c8917232a85d0277819ca82d279aee.png)

elasticsearch.exceptions.RequestError: RequestError(400, 'invalid\_index\_name\_exception', 'Invalid index name [\_ingest/pipeline/attachment\_pipeline], must not contain the following characters ['','/','\*  
','?','"','\<','\>','|',' ',',']')

If you just run it, it will come out like this: It looks like you have / in your index name. So this time I only ran the bottom part.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/7/f75496a5f6b02c244795ef52be29dbb160beee88.png)

elasticsearch.exceptions.RequestError: RequestError(400, 'illegal\_argument\_exception', 'pipeline with id [attachment\_pipeline] does not exist')

..........

I want to know how to use it..

How to make attachment plugin work in python

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [January 17, 2023, 4:50am UTC](https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286/2 "2023-01-17T04:50:32Z")

</div>

Welcome to our community! 😃

Please don't post pictures of text, logs or code. They are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them 🙂

---

<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: [January 17, 2023, 7:45am UTC](https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286/3 "2023-01-17T07:45:34Z")

</div>

You need to encode the binary content to BASE64 and then put the BASE64 into the data field.

Also you need to use the PUT ingest pipeline API and not the Create Index API.

---

<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: [February 14, 2023, 7:45am UTC](https://discuss.elastic.co/t/how-to-use-elasticsearch-8-x-ingest-attachment-with-python/323286/4 "2023-02-14T07:45:52Z")

</div>

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