我正在尝试索引很多记录,但是在索引plugman install ...
字段时遇到了一些麻烦。我默认将该字段映射为日期和格式,但是
我收到此错误:
错误:400 {“错误”:{“ root_cause”:[{“ type”:“ mapper_parsing_exception”,“原因”:“无法解析类型为[date]”}的字段[publish_up],]“,” type“ :“ mapper_parsing_exception”,“原因”:“无法解析类型为[date]的字段[publish_up]”,“ caused_by”:{“ type”:“ illegal_argument_exception”,“原因”:“无效格式:\” 2015-02 -11 00:00:00 \“格式错误,表示为\” 00:00:00 \“”}},“状态”:400}
这是我配置索引的方式:
publish_up
和索引代码(这里出现错误):
$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
。我检查了Documentation,但无法解决问题。
答案 0 :(得分:0)
由于日期格式不是标准的ISO8601(日期和时间之间缺少T
),因此您需要在映射中添加格式。您确实这样做了,但是模式是错误的,因为您使用YYYY
多年而不是yyyy
,并且使用mm
几个月而不是MM
。尝试这样:
'publish_up' => [ 'type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'],
^ ^
| |
change these