# How to send a text file to elasticsearch with rest api

**URL:** <https://discuss.elastic.co/t/how-to-send-a-text-file-to-elasticsearch-with-rest-api/199745>\
**Category:** Elasticsearch\
**Created:** [September 17, 2019, 2:22am UTC](https://discuss.elastic.co/t/how-to-send-a-text-file-to-elasticsearch-with-rest-api/199745 "2019-09-17T02:22:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atline/32/119772_2.png) [@atline](https://discuss.elastic.co/u/atline)\
**Post date:** [September 17, 2019, 2:22am UTC](https://discuss.elastic.co/t/how-to-send-a-text-file-to-elasticsearch-with-rest-api/199745/1 "2019-09-17T02:22:58Z")

</div>

I have a log file which I want to send to elasticsearch.

**log.txt:**

```
abc
de
fg

```

The problem is:

1. If I use filebeat, it will treat every line as a document. Of course, I could set some multiline regular expression, but here no special rules I could give because file contents are different from files to files.

2. Then, I tried to send the whole contents of files to elasticsearch like next:

My question is, do we have some command which could directly send a text file's contents to elasticsearch? Or any sdk could help me?

---

<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 17, 2019, 3:26pm UTC](https://discuss.elastic.co/t/how-to-send-a-text-file-to-elasticsearch-with-rest-api/199745/2 "2019-09-17T15:26:22Z")

</div>

Have a look at FSCrawler project. This might help you.

---

<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 15, 2019, 3:26pm UTC](https://discuss.elastic.co/t/how-to-send-a-text-file-to-elasticsearch-with-rest-api/199745/3 "2019-10-15T15:26:23Z")

</div>

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