# Import Json file by using Sense Interface

**URL:** <https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398>\
**Category:** Elasticsearch\
**Created:** [April 26, 2016, 8:41am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398 "2016-04-26T08:41:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saba\_soltani](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saba\_soltani](https://discuss.elastic.co/u/saba_soltani)\
**Post date:** [April 26, 2016, 8:41am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/1 "2016-04-26T08:41:46Z")

</div>

Hi

I'm new in elasticsearch. I have created a new index and defined its mapping .  
I want to import a json file from my computer into elasticsearch by using sense in order to analyze it in kibaba. How can I do 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:** [April 26, 2016, 10:36am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/2 "2016-04-26T10:36:39Z")

</div>

What does the JSON file look like?

If you have a lot of docs, you can use [Bulk API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html) for that. But note that you need headers.

---

<div class="post-metadata">

**Author:** ![saba\_soltani](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saba\_soltani](https://discuss.elastic.co/u/saba_soltani)\
**Post date:** [April 26, 2016, 10:51am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/3 "2016-04-26T10:51:08Z")

</div>

My json file looks like as following:  
[{"id" : 24567, "source" : "Personal" , "startTime" : "2015-05-04 19:05:53"....},{"id" : 24568, "source" : "Personal" ,"startTime" : "2015-05-04 20:05:53"....},{"id" : 24569, "source" : "Personal" , "startTime" : "2015-05-04 19:10:53"....} ,...]

And number of document is very high (around 3 million)  
when I am using the following code in sense , It is not working

POST /my\_index -d @"C:\MyComputer...\file.json"

But the point is, how can i use Bulk API in sense and add the headers ?

thank you so much for your help

---

<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:** [April 26, 2016, 11:33am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/4 "2016-04-26T11:33:36Z")

</div>

Sense is not intended to send 3m records. That's "just" a console to play with/manage elasticsearch.

Can you generate your 3m documents in another format than this one?  
If not, it means that you will have to pre-process them with something like Logstash or any ETL tool you like.

If you can, that's better.

Generate in that case a file which is looking like:

```auto
{ "index" : { "_id" : "24567" } }
{"id" : 24567, "source" : "Personal" , "startTime" : "2015-05-04 19:05:53"....}
{ "index" : { "_id" : "24568" } }
{"id" : 24568, "source" : "Personal" ,"startTime" : "2015-05-04 20:05:53"....}

```

Generate a file for every 10000 doc for example. Then you can send those files using a `curl` command (although it could be hard on windows!).

If you generate one file per document, you could also use fscrawler with this option: [https://github.com/dadoonet/fscrawler#indexing-json-docs](https://github.com/dadoonet/fscrawler#indexing-json-docs) but I'm unsure it will work well for 3m docs...

Another question is where is this data coming from? That might change the answer I'm giving...

---

<div class="post-metadata">

**Author:** ![saba\_soltani](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saba\_soltani](https://discuss.elastic.co/u/saba_soltani)\
**Post date:** [April 26, 2016, 11:45am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/5 "2016-04-26T11:45:13Z")

</div>

Thank you so much for your quick response.  
About format of document, I can say that:

The data is an output of R and the original format is .Rdata . I converted this format to .json in R to import into elasticsearch. But I can have .txt and .csv format of data file.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 27, 2016, 5:34am UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/6 "2016-04-27T05:34:38Z")

</div>

You would be better of using Logstash, or something else.

---

<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 5, 2017, 10:56pm UTC](https://discuss.elastic.co/t/import-json-file-by-using-sense-interface/48398/7 "2017-07-05T22:56:08Z")

</div>


