I am very new to elasticsearch and implementing elasticsearch in php-laravel based API using elasticsearch-php client. I am saving 2 datetime fields (created_on, modified_on) from the sql db which I want to index in problem document. Ar first I didn't give date format for properties in mapping.
'index' => 'newproblemindex',
'type' => 'newproblems2',
'body' => [
'newproblems2' => [
'_source' => [
'enabled' => true
],
'properties' => [
'subject' => [
'type' => 'text',
'analyzer' => 'standard',
],
'notes' => [
'type' => 'text',
'analyzer' => 'standard'
],
'created_on' => [
'type' => 'date',
],
'modified_on' => [
'type' => 'date',
],
'created_by' => [
'type' => 'integer',
],
'modified_by' => [
'type' => 'integer',
],
'status_enum' => [
'type' => 'integer',
],
'rating' => [
'type' => 'integer',
]
]
]
]
];
so when I tried to index my document I got the error
Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [created_on]"}],"type":"mapper_parsing_exception","reason":"failed to parse [created_on]","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:100"}},"status":400} in file /var/www/development/api/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 615
So I tried to update the mapping using put mapping
'index' => 'newproblemindex',
'type' => 'newproblems2',
'body' => [
'newproblems2' => [
'_source' => [
'enabled' => true
],
'properties' => [
'subject' => [
'type' => 'text',
'analyzer' => 'standard',
],
'notes' => [
'type' => 'text',
'analyzer' => 'standard'
],
'created_on' => [
'type' => 'date',
'format' => "Y-m-d H:i:s"
],
'modified_on' => [
'type' => 'date',
'format' => "Y-m-d H:i:s"
],
'created_by' => [
'type' => 'integer',
],
'modified_by' => [
'type' => 'integer',
],
'status_enum' => [
'type' => 'integer',
],
'rating' => [
'type' => 'integer',
]
]
]
]
];
but now I am getting error
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Invalid format: [Y-m-d H:i:s]: Illegal pattern component: i"}],"type":"illegal_argument_exception","reason":"Invalid format: [Y-m-d H:i:s]: Illegal pattern component: i","caused_by":{"type":"illegal_argument_exception","reason":"Illegal pattern component: i"}},"status":400}
how can I remove the error what am I doing wrong, any help would be appreciated
Thanks for your help in advance