【发布时间】:2019-06-11 21:18:48
【问题描述】:
我正在尝试索引很多记录,但是在索引 publish_up 字段时遇到了一些麻烦。我默认将该字段映射为日期和格式,但是
我收到此错误:
错误:400 {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"无法解析 [date] 类型的字段 [publish_up]"}],"type" :"mapper_parsing_exception","reason":"无法解析 [date] 类型的字段 [publish_up]","caused_by":{"type":"illegal_argument_exception","reason":"格式无效:\"2015-02 -11 00:00:00\" 在 \" 00:00:00\""}},"status":400}
处格式不正确
这是我配置索引的方式:
$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);
和索引代码(这里我得到错误):
$params = [
'index' => 'attachments',
'type' => 'documentos',
'id' => $datos->id,
'body' => [
'iddoc' => $datos->id,
'publish_up' => $datos->publish_up,
'textofull' => $datos->fulltext
]
];
$response = $client->index($params);
注意: $datos->publish_up 的日期格式为 2015-02-11 00:00:00。我检查了Documentation,但我无法解决我的问题。
【问题讨论】:
标签: php elasticsearch