# ElasticSearch PHP api -\>search does not work

**URL:** <https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355>\
**Category:** Elasticsearch\
**Created:** [January 2, 2017, 12:03pm UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355 "2017-01-02T12:03:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas\_Mangipudi](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Srinivas\_Mangipudi](https://discuss.elastic.co/u/Srinivas_Mangipudi)\
**Post date:** [January 2, 2017, 12:03pm UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355/1 "2017-01-02T12:03:48Z")

</div>

I am trying to use the ElasticSearch php api. I have specified the hosts, build a ElasticSearch client using that.

$params = [  
'index' =\> 'queue\_pings',  
'type' =\> 'QueuePings',  
'id' =\> 'AVlXjC8N9CsgaVAfEIZE'  
];

When I use $client-\>get($params) it works. But when try to use the search function, i get err\_invalid\_req. Can't seem to find out why, have also used extended hosts config etc...

my params for search functions are:  
$params = [  
'index' =\> 'queue\_pings',  
'type' =\> 'QueuePings',  
'body' =\> [  
'query' =\> [  
'match' =\>[  
'id' =\> 'AVlXjC8N9CsgaVAfEIZE'  
]  
]  
]  
];

---

<div class="post-metadata">

**Author:** ![amar-tari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amar-tari/32/14243_2.png) [@amar-tari](https://discuss.elastic.co/u/amar-tari)\
**Post date:** [January 2, 2017, 1:55pm UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355/2 "2017-01-02T13:55:23Z")

</div>

Hi,

I use to face same issue for search using "match", this can be fix if you are defining following when creating index , Please try  
"id" : { "type" : "string", **"index" : "not\_analyzed"** },

I hope this will fix your issue, Regards Amar

---

<div class="post-metadata">

**Author:** ![Srinivas\_Mangipudi](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Srinivas\_Mangipudi](https://discuss.elastic.co/u/Srinivas_Mangipudi)\
**Post date:** [January 3, 2017, 6:17am UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355/3 "2017-01-03T06:17:26Z")

</div>

Thanks Amar.

I am also getting the same squid error page when I use a curl -xget search on terminal. There is some problem processing the request.

curl -XGET [http://myelasticsearchsite.com:80/bt\_orders/\_search](http://myelasticsearchsite.com:80/bt_orders/_search) -d '  
{  
"aggs" : {  
"max\_modified" : {  
"max" : {"field" : "order.modified" } }

}'

give the following squid error page:

**Invalid Request** error was encountered while trying to process the request:

---

<div class="post-metadata">

**Author:** ![amar-tari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amar-tari/32/14243_2.png) [@amar-tari](https://discuss.elastic.co/u/amar-tari)\
**Post date:** [January 3, 2017, 6:39am UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355/4 "2017-01-03T06:39:01Z")

</div>

Hi Srinivas,

You are missing one closing bracket, Please add one more "}" at the end and try running, should work. Regards, Amar

---

<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:** [January 31, 2017, 6:39am UTC](https://discuss.elastic.co/t/elasticsearch-php-api-search-does-not-work/70355/5 "2017-01-31T06:39:04Z")

</div>

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