# What is the best and fatest way to insert json data into elasticsearch

**URL:** <https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225>\
**Category:** Elasticsearch\
**Created:** [September 19, 2019, 2:16pm UTC](https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225 "2019-09-19T14:16:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NAL](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@NAL](https://discuss.elastic.co/u/NAL)\
**Post date:** [September 19, 2019, 2:16pm UTC](https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225/1 "2019-09-19T14:16:13Z")

</div>

Hi,

I have many json files (about 200 per day, each file contains more than 300 000 lines) that i need to insert into elasticsearch index.

I'm looking for a way to say to elasticsearch to get each json file in a folder, and put each row into an index mapping the correct fields. And I must do it fast (best will be less than 30 min.)

Is it possible to "industrialize" this process with filebeat/ logstash or another one ?

I tried a simple bulk insert using elasticsearch .net and nest api but it takes too many times to do it (about 3/4 min per file)

I did some test with filebeat but all I achieved is to insert the json data into the field message of a log..In my case, this is not what I'm looking for.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 19, 2019, 4:44pm UTC](https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225/2 "2019-09-19T16:44:44Z")

</div>

What is the size and specification of your cluster? Have you identified what is the bottleneck?

---

<div class="post-metadata">

**Author:** ![NAL](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@NAL](https://discuss.elastic.co/u/NAL)\
**Post date:** [September 20, 2019, 8:10am UTC](https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225/3 "2019-09-20T08:10:05Z")

</div>

My cluster is 1 shard / 1 replica and the size is about 600Mo/1gb when I index 20 files

I tried to upgrade the number of shards and replicas to 4/4 and the time for indexing 20 json files with bulk insert .NET is reduce to the half.

I advanced in my test :

I used json decode in filebeat and it works. Now, I can see my data (Name,Unit,Value,geo and Time) but I also see all another logs fields that I don't want in my mapping.

 ![mapping](https://us1.discourse-cdn.com/elastic/original/3X/a/d/ad61b63bf5fa2be7ddc0c455c7a4ff87b38076fe.png)

Also, The geo data is not recognize as geo point type. Is there something to add in config ?

I tried to do my own template but it seems that filebeat don't take it. btw: the bulk with filebeat :

20 json files with total lines around 5 millions takes 19 minutes !! IS it normal ? for me, it seems very very slow..

Same files with bulk insert in c# is about 3/4 minutes.

---

<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 18, 2019, 8:10am UTC](https://discuss.elastic.co/t/what-is-the-best-and-fatest-way-to-insert-json-data-into-elasticsearch/200225/4 "2019-10-18T08:10:17Z")

</div>

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