yii2-elasticsearch: elasticSeach 6 , error : Content-Type header [application/x-www-form-urlencoded] is not supported

Elasticsearch Database Exception – yii\elasticsearch\Exception

Elasticsearch request failed with code 406.

Error Info: Array
(
    [requestMethod] => PUT
    [requestUrl] => http://127.0.0.1:9200/fecshop_product_en/_mapping/product
    [requestBody] => {"product":{"properties":{"product_id":{"type":"integer","index":"not_analyzed"},"name":{"type":"text","analyzer":"english"},"short_description":{"type":"text","analyzer":"english"},"description":{"type":"text","analyzer":"english"},"spu":{"type":"keyword","index":"not_analyzed"},"sku":{"type":"keyword","index":"not_analyzed"},"score":{"type":"integer","index":"not_analyzed"},"status":{"type":"integer","index":"not_analyzed"},"is_in_stock":{"type":"string","index":"not_analyzed"},"url_key":{"type":"keyword","index":"not_analyzed"},"price":{"type":"float","index":"not_analyzed"},"cost_price":{"type":"float","index":"not_analyzed"},"special_price":{"type":"intfloateger","index":"not_analyzed"},"special_from":{"type":"integer","index":"not_analyzed"},"special_to":{"type":"integer","index":"not_analyzed"},"final_price":{"type":"float","index":"not_analyzed"},"image":{"type":"text","index":"not_analyzed"},"created_at":{"type":"integer","index":"not_analyzed"},"sync_updated_at":{"type":"float","index":"not_analyzed"}}}}
    [responseCode] => 406
    [responseHeaders] => Array
        (
            [content-type] => application/json; charset=UTF-8
            [content-length] => 97
        )

    [responseBody] => Array
        (
            [error] => Content-Type header [application/x-www-form-urlencoded] is not supported
            [status] => 406
        )

)


485486487488489490491492493494495496497498499500501502503

                    'requestBody' => $requestBody,
                    'responseCode' => $responseCode,
                    'responseHeaders' => $headers,
                    'responseBody' => $this->decodeErrorBody($body),
                ]);
            }
        } elseif ($responseCode == 404) {
            return false;
        } else {
            throw new Exception("Elasticsearch request failed with code $responseCode.", [
                'requestMethod' => $method,
                'requestUrl' => $url,
                'requestBody' => $requestBody,
                'responseCode' => $responseCode,
                'responseHeaders' => $headers,
                'responseBody' => $this->decodeErrorBody($body),
            ]);
        }
    }


About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

my elasticsearch version is 6, I have solved this problem

Connection.php

377 line

CURLOPT_HTTPHEADER     => ['Expect:'],

change to:

CURLOPT_HTTPHEADER    => [
                'Accept: application/json',
                'Content-Type: application/json'
			],

solved!