# Import big JSON to Elasticstearch

**URL:** <https://discuss.elastic.co/t/import-big-json-to-elasticstearch/33868>\
**Category:** Elasticsearch\
**Created:** [November 5, 2015, 1:07pm UTC](https://discuss.elastic.co/t/import-big-json-to-elasticstearch/33868 "2015-11-05T13:07:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryodo](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ryodo](https://discuss.elastic.co/u/ryodo)\
**Post date:** [November 5, 2015, 1:07pm UTC](https://discuss.elastic.co/t/import-big-json-to-elasticstearch/33868/1 "2015-11-05T13:07:21Z")

</div>

I need to import a lot of data as individual json file to elasticsearch . I use this code

```
$re = "select * from tweecoms limit 10";
    $r = $Acc->Select($re);
$i=0;
while ($k = $r->fetch()) {
    $json_doc[] = array(
        "association_key" => $k['id'],
        "text" => $k['text']
    );        
}
    $json_doc= json_encode($json_doc);
    //var_dump($json_doc);exit();
$baseUri = 'http://127.0.0.1:9200/myindex2/tweecoms2/_bulk';
    $ci = curl_init();
    curl_setopt($ci, CURLOPT_URL, $baseUri);
    curl_setopt($ci, CURLOPT_PORT, $search_port);
    curl_setopt($ci, CURLOPT_TIMEOUT, 200);
    curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ci, CURLOPT_FORBID_REUSE, 0);
    curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($ci, CURLOPT_POSTFIELDS, $json_doc);
    echo curl_exec($ci);
    curl_close($ci);

```

How i can send my `$json_doc` to elasticsearch ?

And whats the link i went use to do this `$baseUri`

English is not my native language, sorry for any mistakes.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 5, 2015, 1:17pm UTC](https://discuss.elastic.co/t/import-big-json-to-elasticstearch/33868/2 "2015-11-05T13:17:13Z")

</div>

Is this PHP? If so you're better off using the [PHP client](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) rather than rolling your own curl commands.

---

<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, 11:40pm UTC](https://discuss.elastic.co/t/import-big-json-to-elasticstearch/33868/3 "2017-07-05T23:40:21Z")

</div>


