Using Elasticsearch-PHP version 6.0 I got the following error:
Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/domaines.nc/_doc] contains unrecognized parameter: [timestamp]"}],"type":"illegal_argument_exception","reason":"request [/domaines.nc/_doc] contains unrecognized parameter: [timestamp]"},"status":400} in /var/www/html/utnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:615 Stack trace: #0 /var/www/html/utnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(279): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/utnc/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections{closure}(Array) #2 /var/www/html/utnc/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL) #3 /var/www/html/utnc/vendor/guzzlehttp/ringphp/src/Core.php(341): in /var/www/html/utnc/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 615
public function indexDocument($client, $domain)
{
$params = [
'index' => 'domaines.nc',
'type' => '_doc',
'routing' => 'company_xyz',
'timestamp' => "2018-05-03T00:00:01.000Z",
'body' => ['nom' => $domain]
];
$response = $client->index($params);
print_r($response);
Elasticsearch doesn't have a timestamp URL parameter. Were you wanting to add that as part of the document as a field?
public function indexDocument($client, $domain)
{
$params = [
'index' => 'domaines.nc',
'type' => '_doc',
'routing' => 'company_xyz',
'body' => [
'nom' => $domain,
'timestamp' => "2018-05-03T00:00:01.000Z"
]
];
$response = $client->index($params);
print_r($response);
Well, I should say, ES doesn't have a timestamp URL parameter _any more_. :)
There used to be a timestamp param to be used with TTL (https://www.elastic.co/guide/en/elasticsearch/reference/2.0/mapping-timestamp-field.html), but that was 2.0 and earlier. It has since been removed.
Thanks, it works, BR
Well, I should say, ES doesn't have a
timestampURL parameter _any more_. :)There used to be a timestamp param to be used with TTL (https://www.elastic.co/guide/en/elasticsearch/reference/2.0/mapping-timestamp-field.html), but that was 2.0 and earlier. It has since been removed.
The documentation for 6.0 still refers to it:
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_documents.html
And the error message when using an "invalid" parameter (other than "timestamp") includes "timestamp" in the list of allowed parameters:
Allowed parameters are "client", "consistency", "custom", "filter_path", "human", "op_type", "parent", "percolate", "pipeline", "refresh", "replication", "routing", "timeout", "timestamp", "ttl", "version", "version_type"
Basically, there is no default timestamp field and you can use any name you want inside the document body.
See https://discuss.elastic.co/t/-timestamp-deprecated/38514 and https://github.com/elastic/elasticsearch/issues/15644