failed to parse field [datefield] of type [date]
Since your date format is not standard ISO8601 (missing the T
between the date and the time), you need to add a format in your mapping. You did, but the pattern was wrong, as you used YYYY
for years instead of yyyy
and mm
for months instead of MM
. Try like this:
'publish_up' => [ 'type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'],
^ ^
| |
change these
Rene Limon
learner and helper. always I want to see what happen js, ES6, ES7, react, next, typescript, graphql, joomla, jquery, php, js, sql, css, java, xml, android, mysql, elasticsearch, linux, git, ubuntu.
Updated on June 20, 2022Comments
-
Rene Limon almost 2 years
I'm trying to index a lot of records but I'm facing some troubles when index
publish_up
field. I mapped that field as date and format by default but I get this error:Error: 400 {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse field [publish_up] of type [date]"}],"type":"mapper_parsing_exception","reason":"failed to parse field [publish_up] of type [date]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2015-02-11 00:00:00\" is malformed at \" 00:00:00\""}},"status":400}
This is how I configure index:
$params = [ 'index' => 'attachments', 'body' => [ 'settings' => [ 'number_of_shards' => 1, 'analysis' => [ 'analyzer' => [ 'custom_analizer_texto_sub' => [ 'type' => 'custom', 'tokenizer' => 'keyword', 'filter' => ['lowercase'] ] ] ] ], 'mappings' => [ 'article' => [ '_source' => [ 'enabled' => true ], 'properties' => [ 'iddoc' => [ 'type' => 'integer'], 'publish_up' => [ 'type' => 'date'],//, 'format' => 'YYYY-mm-dd HH:mm:ss'], //Y/m/d H:i:s 'textofull' => [ 'type' => 'keyword'] ] ] ] ] ]; $response = $client->indices()->create($params);
And index code (here I get the error):
$params = [ 'index' => 'attachments', 'type' => 'documentos', 'id' => $datos->id, 'body' => [ 'iddoc' => $datos->id, 'publish_up' => $datos->publish_up, 'textofull' => $datos->fulltext ] ]; $response = $client->index($params);
NOTE:
$datos->publish_up
has this dateformat2015-02-11 00:00:00
. I checked Documentation but I can't solve my problem.