I'm trying to use Elasticsearch-php version 5.0 to send search queries to Elasticsearch 6.4.2.
One of the breaking changes from 5.0 to 6.0 is that there is the "strict content type validation" which means that requests to Elasticsearch must sent with "Content-type: application/json" header.
In order to add this header, I tried to use polyfractal's suggestion from this thread:
$params = [
'index' => $index,
'type' => $mapping,
'body' => $query,
'client' => [
'curl' => [CURLOPT_HTTPHEADER => array('Content-type: text/plain')]
]
];
$res = $this->mESClient->search($params); // this is Elasticsearch/Client
return $res;
but for some reason, I keep getting "Notice: Array to string conversion" when the code tries to do curl_setopt_array(), and the request is net sent.
Please note: that when I remove the 'client' part of the $params array the request is being received in the Elasticsearch.