Import big JSON to Elasticstearch


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);
while ($k = $r->fetch()) {
    $json_doc[] = array(
        "association_key" => $k['id'],
        "text" => $k['text']
    $json_doc= json_encode($json_doc);
$baseUri = '';
    $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);

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.

(Magnus B├Ąck) #2

Is this PHP? If so you're better off using the PHP client rather than rolling your own curl commands.

(system) #3