Php 弹性搜索don';不允许在日期字段中为空索引
我有以下数据要索引:Php 弹性搜索don';不允许在日期字段中为空索引,php,
elasticsearch,Php,
elasticsearch,我有以下数据要索引: array:6 [▼ "index" => "my_index" "type" => "audit_field" "id" => "57f36d28a1dfc" "parent" => "57f36d289f1b2" "routing" => 318 "body" => array:19 [▼ "session_id" => 318 "trans_seq_no" => 13
array:6 [▼
"index" => "my_index"
"type" => "audit_field"
"id" => "57f36d28a1dfc"
"parent" => "57f36d289f1b2"
"routing" => 318
"body" => array:19 [▼
"session_id" => 318
"trans_seq_no" => 13
"table_seq_no" => 13
"field_id" => 65
"field_name" => "id"
"new_value" => 45
"old_value" => 45
"date_type_new_value" => null
"date_type_old_value" => null
"time_type_new_value" => null
"time_type_old_value" => null
]
]
我将自己定义为bellow
array(
'index' => 'promote_kmp',
'type' => 'audit_field',
'body' => [
'audit_field' => [
'_source' => [
'type' => 'string'
],
"_parent" => [
"type" => "audit_table"
],
'properties' => [
'session_id' => array('type' => 'string'),
'trans_seq_no' => array('type' => 'string'),
'table_seq_no' => array('type' => 'string'),
'field_id' => array('type' => 'string'),
'field_name' => array('type' => 'string'),
'old_value' => array(
'type' => 'string'
),
'new_value' => array(
'type' => 'string'
),
'date_type_new_value' => array(
'type' => 'date',
'format' =>'YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd'
),
'date_type_old_value' => array(
'type' => 'date',
'format' =>'YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd'
),
'time_type_new_value' => array(
'type' => 'date',
'format' => 'HH:mm:ss'
),
'time_type_old_value' => array(
'type' => 'date',
'format' => 'HH:mm:ss'
)
]
]
]
);
但当我想在日期字段中用null索引数据时,elasticsearch显示了一个异常,无法用映射日期格式类型解析日期字段值。
如何解决这个问题,我也试着用空的,但不工作,并给出同样的信息
MapperParsingException[failed to parse [date_type_new_value]]; nested:
MapperParsingException[failed to parse date field [], tried both date format
[YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd], and timestamp
number with locale []]; nested: IllegalArgumentException[Invalid format: ""];
我不确定为什么null不起作用,我可以在ES 1.7中为null值编制索引,也可以
IllegalArgumentException[无效格式:“”代码>表示空白字符串且不是空值
如果您无法控制数据,则需要使用不为日期字段编制索引,而是正常为文档编制索引的属性。使用ES 7,您可以选择将null\u值指定为字段属性。但是,无法搜索空值。
有关null\u值
配置和日期数据类型,请参阅。我可以控制数据,我传递了null值,但显示了错误。我使用的是同一版本的elastic。这很奇怪,你能试着在映射中添加ignore_畸形吗?