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

**URL:** <https://discuss.elastic.co/t/how-to-add-hash-response-in-the-params-body-of-elasticsearch-php-api/98484>\
**Category:** Elasticsearch\
**Created:** [August 27, 2017, 5:16pm UTC](https://discuss.elastic.co/t/how-to-add-hash-response-in-the-params-body-of-elasticsearch-php-api/98484 "2017-08-27T17:16:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)\
**Post date:** [August 27, 2017, 5:16pm UTC](https://discuss.elastic.co/t/how-to-add-hash-response-in-the-params-body-of-elasticsearch-php-api/98484/1 "2017-08-27T17:16:16Z")

</div>

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);
```

---

<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:** [September 24, 2017, 5:20pm UTC](https://discuss.elastic.co/t/how-to-add-hash-response-in-the-params-body-of-elasticsearch-php-api/98484/2 "2017-09-24T17:20:12Z")

</div>

Closed on September 24, 2017, 5:20pm UTC

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