# Importing text from text files and merging to existing documents

**URL:** <https://discuss.elastic.co/t/importing-text-from-text-files-and-merging-to-existing-documents/278269>\
**Category:** Logstash\
**Created:** [July 9, 2021, 10:28am UTC](https://discuss.elastic.co/t/importing-text-from-text-files-and-merging-to-existing-documents/278269 "2021-07-09T10:28:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stashing\_logs](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@stashing\_logs](https://discuss.elastic.co/u/stashing_logs)\
**Post date:** [July 9, 2021, 10:28am UTC](https://discuss.elastic.co/t/importing-text-from-text-files-and-merging-to-existing-documents/278269/1 "2021-07-09T10:28:29Z")

</div>

I have an existing elastic engine containing documents with an ID and some metadata (date, original file path, author etc.).

I now have the text files which have the extracted text for these documents. The text files are "\<document\_id\>.txt" all sitting in a folder.

The configuration file then has:

```auto
intput {
file{
path => "/FileData/Sourcefolder/*.txt
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
output {
action => update
(url, api_key, engine etc. as used for the first upload)
}

```

Is there a way I can reference the file name of the input file? I want something like:  
"document\_id" =\> fileName  
"full\_text" =\> fileText

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 9, 2021, 4:43pm UTC](https://discuss.elastic.co/t/importing-text-from-text-files-and-merging-to-existing-documents/278269/2 "2021-07-09T16:43:39Z")

</div>

> [@stashing\_logs](#):
>
> Is there a way I can reference the file name of the input file?

Yes, a file input adds a [path] field to the event.

---

<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:** [August 6, 2021, 4:44pm UTC](https://discuss.elastic.co/t/importing-text-from-text-files-and-merging-to-existing-documents/278269/3 "2021-08-06T16:44:28Z")

</div>

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