# Ingest attachment plugin (Index files multiple time to same \_id)

**URL:** <https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006>\
**Category:** Elasticsearch\
**Created:** [June 29, 2018, 4:30pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006 "2018-06-29T16:30:51Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [June 29, 2018, 4:30pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/1 "2018-06-29T16:30:51Z")

</div>

I had a document stored in Elastic Search under unique id which has an array of pdf files indexed in it along with other information(Name, Phone No, etc...). Now i want to update same document(\_id) by adding new pdf file while keeping the old files too. how i can update the document?

---

<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 29, 2018, 5:55pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/2 "2018-06-29T17:55:01Z")

</div>

I believe you need to reindex the whole document with old PDFs + the new one.

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 3, 2018, 5:12pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/3 "2018-07-03T17:12:46Z")

</div>

hi,  
is there any alternative for this because i want to keep the old files and add new ones.  
Re-indixing will took to much time. consider a document already had 50 files and to add one new file i need to index 51 files.  
is there any possible solution for this issue?  
thanks

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 3, 2018, 5:14pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/4 "2018-07-03T17:14:43Z")

</div>

or any other way to store all files under same document(\_id)?

---

<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:** [July 3, 2018, 5:29pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/5 "2018-07-03T17:29:49Z")

</div>

The solution IMO (and this is what I did in the past) is to denormalize the content.

Instead of indexing something like:

```auto
PUT attachments/_doc/bar
{
  "foo": "bar",
  "attachments": [
    { "id": "bar1", "content": "BASE64"},
    { "id": "bar2", "content": "BASE64"},
    { "id": "bar3", "content": "BASE64"}
  ]
}

```

I was indexing:

```auto
PUT attachment/_doc/bar1
{
  "foo": "bar",
  "content": "BASE64"
}
PUT attachment/_doc/bar2
{
  "foo": "bar",
  "content": "BASE64"
}
PUT attachment/_doc/bar3
{
  "foo": "bar",
  "content": "BASE64"
}

```

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 3, 2018, 7:22pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/6 "2018-07-03T19:22:37Z")

</div>

thanks alot.

so it means there is no way to store all file under same document id over time?

because my main concern here is to keep the document id same.

---

<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:** [July 3, 2018, 8:33pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/7 "2018-07-03T20:33:45Z")

</div>

Multiple documents can not share the same id.  
You can look at parent child feature if really needed.

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 4, 2018, 8:41pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/8 "2018-07-04T20:41:50Z")

</div>

thanks

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 5, 2018, 4:35pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/9 "2018-07-05T16:35:41Z")

</div>

hi,

I made some changes to my docker file i.e. i change only base image and add few lines to install ingest attachment plugin.  
I think i lost my data. is it supposed to be? because i did not change volume mounts.  
How can i recover lost data and quick way to re index it?

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:** [July 5, 2018, 7:26pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/10 "2018-07-05T19:26:30Z")

</div>

> [@workland](#):
>
> I think i lost my data. is it supposed to be?

No. Probably a bad usage of docker IMHO.

> How can i recover lost data and quick way to re index it?

I don't know...

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 9, 2018, 4:46pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/11 "2018-07-09T16:46:09Z")

</div>

hi David,  
I have to index thousand of files (pdf, docx, etc) and i am worried about not to index the same file 2 or more times. is there any way to distinguish between files content before indexing?  
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:** [July 23, 2018, 8:44am UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/12 "2018-07-23T08:44:24Z")

</div>

The only way to do that IMO is to compute a fingerprint before indexing the document based on whatever fields you have and index that fingerprint as a field or as the `_id`.

If you are using it as the `_id` you can use the `_create` API which will reject any document that has been already indexed.

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 30, 2018, 7:51pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/13 "2018-07-30T19:51:48Z")

</div>

![Screenshot%20from%202018-07-30%2015-44-16](https://us1.discourse-cdn.com/elastic/original/3X/2/5/2533bb4daf22b0e3fbf4084da64af6c17f721785.png)

hi,  
In image you can see two document are indexed.  
i have to make a join query to match attachment.content filed from one doc with user defined input but having a where condition matches from other document like a join(Employer\_id filed from other document)  
i have join relationship.  
Any suggestions how to make a join query?  
thanks in advance

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [July 30, 2018, 7:59pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/14 "2018-07-30T19:59:27Z")

</div>

my use case and my proposed design is basically like :  
-index every document(resume, cover letter etc) come to our system for each user(candidate). i indexed each file separately with some user information (this is my Parent document)

-when user apply for a job i need to create another doc to keep track of that this document is now refereed to this job or employer. I indexed new document which has information related to employer.this is my child doc.

-i can get all parents from child(by searching inside child) or all child from parent(search inside parent).

-is there any way i can search in both parent and child in one search query at same time and it returns the results if join works? in my case i have to match one filed from parent doc and other from child doc and then get results if both matches?

---

<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:** [July 31, 2018, 8:58pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/15 "2018-07-31T20:58:31Z")

</div>

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with `</>` icon. Check the preview window.

> Any suggestions how to make a join query?

Elasticsearch does not support joins. Unless you are using parent/child but you need to understand what are the pro/cons of using that.

Instead, I'd index within each document all the information about the user. Basically I'd do joins at index time and index one single document.

Not sure if it fits your use case though but the important thing to recall is that Elasticsearch is not a relational system.

My 0.02 cents.

---

<div class="post-metadata">

**Author:** ![workland](https://avatars.discourse-cdn.com/v4/letter/w/aeb1de/32.png) [@workland](https://discuss.elastic.co/u/workland)\
**Post date:** [August 13, 2018, 10:29pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/16 "2018-08-13T22:29:31Z")

</div>

hi i am getting an error while adding filter=\>lowercase on analyzer type=\>keyword ? is it possible to have it?  
Actually i want to apply lowercase filter on a particular field?  
thanks

---

<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:** [September 10, 2018, 10:29pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-index-files-multiple-time-to-same-id/138006/17 "2018-09-10T22:29:33Z")

</div>

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