Hi friends,
already 3 days I am fighting with tutorials for Elasticsearch, how to install it, how to use it with php etc.
Currently I have elasticsearch on server (debian 8) hopefully working, but I can't work with php.
I use just small part of code:
require 'vendor/autoload.php';
$client = Elasticsearch\ClientBuilder::create()->build();
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
'body' => ['testField' => 'abc']
];
$response = $client->index($params);
print_r($response);
And I get:
Notice: Use of undefined constant JSON_PRESERVE_ZERO_FRACTION - assumed 'JSON_PRESERVE_ZERO_FRACTION' in /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Serializers/SmartSerializer.php on line 30
Warning: json_encode() expects parameter 2 to be long, string given in /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Serializers/SmartSerializer.php on line 30
Fatal error: Uncaught exception 'Elasticsearch\Common\Exceptions\BadRequest400Exception' with message '{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse, document is empty"}],"type":"mapper_parsing_exception","reason":"failed to parse, document is empty"},"status":400}' in /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:681 Stack trace: #0 /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(659): Elasticsearch\Connections\Connection->tryDeserializeError(Array, 'Elasticsearch\C...') #1 /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(579): Elasticsearch\Connections\Connection->tryDeserialize400Error(Array) #2 /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(261): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #3 /var/www/nnc/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\ in /var/www/nnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 682
I am running on debian 8 Jessie, php 5.6.27 (newest in repository).
Are you able to help me what's the trouble?