How to Add hash response in the params body of Elasticsearch PHP API


(Ritesh) #1

Hi

I have tweeter response , which i get using REST URL code.

print_r($tweets) ;

This response is in hash key format like this

stdClass Object ( [statuses] => Array ( [0] => stdClass Object ( [created_at] => Sat Aug 26 05:17:05 +0000 2017 [id] => 1234567890 [id_str] => 1234567890 [text] => RT..........

Now i want to index this response in elasticsearch using PHP client. I am not sure how to define the $tweet response in body of params

 $hosts = ['http://127.0.0.1:9200' ];

$client = ClientBuilder::create()           // Instantiate a new ClientBuilder
                    ->setHosts($hosts)      // Set the hosts
                    ->build();              // Build the client object


$params = [
   'index' => 'hashtag-index',
     'type' => 'hashtag',
     'id' => 'id',
       'body' => [ 'testField' => 'abc']  // this gets index but not the below one, i need for below one
     'body' => ['$tweet'] // this doens't work
 ];


$response = $client->index($params);

(system) #2

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