I am trying this code without success. But after json_decode($row, true); it's work then. Because it is now an array after json_decode();
Note: I want to add json without decode.
$elasticaIndex = $elasticaClient->getIndex('twitter_json');
$elasticaType = $elasticaIndex->getType('tweet_json');
$filename = dirname(__FILE__) . "/twitter.txt";
$fh = fopen($filename, 'r');
$counter = 0;
$documents = array();
while (( $row = fgets($fh)) != false ) {
$jsonTweet = $row;
if ( $jsonTweet == null)
continue;
$documents[] = new \Elastica\Document(uniqid(),$jsonTweet);
$counter++;
if($counter == 500)
break;
}
$elasticaType->addDocuments($documents);
$elasticaType->getIndex()->refresh();