Elasticsearch-php: Probleme indexing a document using 'timestamp' field

Created on 3 May 2018  路  5Comments  路  Source: elastic/elasticsearch-php

Summary of problem or feature request

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

Code snippet of problem

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);

System details

  • Operating System: CentOS 7
  • PHP Version 7.2
  • ES-PHP client version 6.0
  • Elasticsearch version 6.2.4-1

All 5 comments

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 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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adoerrES picture adoerrES  路  5Comments

dinamic picture dinamic  路  5Comments

PascalThesing picture PascalThesing  路  7Comments

ls
ssanchezromero picture ssanchezromero  路  6Comments

amorphine picture amorphine  路  6Comments