現象
Elasticaを利用してElasticsearchにドキュメントを突っ込むと以下が出力される
Content-Type header [application/x-www-form-urlencoded] is not supported
解決方法
単にContent-Typeをapplication/jsonで指定すれば良い。
Elastica/Transport/Httpに以下の処理を追加する。
Http.php
$headers = [];
// 以下の行を追加
$headers[] = 'Content-Type: application/json';
環境
cakephp:3.6.4
cakephp/elastic-search:@stable(バージョン幾つか不明。たぶん1.0)
そもそも公式ドキュメントにある方法に倣っただけだが、
cakephp/elastic-searchの@stableバージョンが依存しているruflin/Elasticaが古い?
ただ、cakephp/elastic-searchの2.0-RC1を使うともっとおかしなことになるので、暫定対処として残します。