ElasticSearch PHP api ->search does not work


(Srinivas Mangipudi) #1

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'
]
]
]
];


(Amar - Persistent Systems) #2

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


(Srinivas Mangipudi) #3

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 -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:


(Amar - Persistent Systems) #4

Hi Srinivas,

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


(system) #5

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