duanqiao2006 2016-10-04 09:32
浏览 515

Elasticsearch不允许在日期字段中索引null

I have bellow data to index:

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
 ]
]

I have defined mapping myself as 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'
                )
            ]
        ]
    ]
);

But when i wan to index data with null in date field, elasticsearch shows and exception that can't parse date field value with mapping date format types. How to solve this, i have also tried with empty, but not working, and give the same message.

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: ""];
  • 写回答

2条回答 默认 最新

  • dsa1234569 2016-10-04 14:11
    关注

    I am not sure why null is not working, I can index null value in ES 1.7, also IllegalArgumentException[Invalid format: ""]; indicates blank string and not null value.

    If you don't have control over the data, you need to use ignore_malformed which will not index the date field but index the document normally.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog