# Some doubt about ingest-attachment

**URL:** <https://discuss.elastic.co/t/some-doubt-about-ingest-attachment/184957>\
**Category:** Elasticsearch\
**Created:** [June 10, 2019, 9:41am UTC](https://discuss.elastic.co/t/some-doubt-about-ingest-attachment/184957 "2019-06-10T09:41:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy\_yan](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@andy\_yan](https://discuss.elastic.co/u/andy_yan)\
**Post date:** [June 10, 2019, 9:41am UTC](https://discuss.elastic.co/t/some-doubt-about-ingest-attachment/184957/1 "2019-06-10T09:41:49Z")

</div>

Hi,team.  
I am new to ElasticSearch.Now I'm working in a project which provide a jsp to search some documents(docx,pdf and so on) of user uploaded.  
I'm using ingest-attachment within ElasticSearch7.0.1,shown in the following code:  
1.declare attachment plugin to ElasticSearch:

```
PUT _ingest/pipeline/attachment
{
  "description" : "Extract attachment information",
  "processors" : [
	{
	  "attachment" : {
		"field" : "data"
	  }
	}
  ]
}

```

2.create a document with attachment:

```
PUT my_index/_doc?pipeline=attachment
{
  "data": "base64..."
}

```

3.now,I can using rest api to search,  
my question is,can I achieve to post the document which content is same as the previous document(I hope the ElasticSearch will updatethe index instead of create anthor one).  
my idea is my program will stored a UUID and the name of document as a key-value into redis,so I will check whether the filename exist or not prior to when I upload a same name of file(Suppose a file with the same name has the same content).If it already exist,the program will using 'PUT my\_index/\_doc/UUID' to update index,otherwise the program will create a new UUID to map current document and save them to Redis,At last the program will call 'POST my\_index/\_doc/UUID' to create data.  
Is it a good idea?If not,What is the best,please help,tks.

---

<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 8, 2019, 9:41am UTC](https://discuss.elastic.co/t/some-doubt-about-ingest-attachment/184957/2 "2019-07-08T09:41:55Z")

</div>

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