Elasticsearch日期字段中的空字符串? [英] Empty string in Elasticsearch date field?

查看:186
本文介绍了Elasticsearch日期字段中的空字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在映射中设置了一个日期字段,如下所示:

I have a date field setup in my mapping like this:

"groupsAssignedDate" : {
    "type" : "date",
    "format" : "MM-dd-YYYY"
}

在我的应用程序中,最初将groupsAssignedDate字段设置为空字符串.分配组后,会生成unix时间戳并将其存储在字段中.我正在尝试使用elasticsearch的批量更新功能来引入一堆文件,其中groupsAssignedDate为",因为尚未分配任何组.Elasticsearch不会将文档编入索引.这是在日志文件中:

In my app, the field groupsAssignedDate is set to the empty string initially. When a group is assigned, a unix timestamp is generated and stored in the field. I'm trying to use elasticsearch's bulk update function to bring in a bunch of documents with a groupsAssignedDate of "" because no groups have been assigned yet. Elasticsearch won't index the docs though. This is in the log file:

Failed to parse [groupsAssignedDate]
...
failed to parse date field [], tried both date format [MM-dd-YYYY], and timestamp number

elasticsearch似乎支持JSON空值...我需要将文档从使用"切换为null还是有某种方法可以支持使用空字符串呢?

It appears elasticsearch supports the JSON null value...do I need to switch my docs from using "" to null or is there some way I can support using the empty string instead?

推荐答案

像您这样的声音可能自己回答过.仅在日期字段中使用null而不是"即可.

Sounds like you may have answered this yourself. Just using null rather than "" in the date field should work.

如果这是一个问题,也许可以考虑从
https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html#ignore-malformed-setting

If that's an issue, maybe consider this from
https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html#ignore-malformed-setting

可以在索引级别上设置 index.mapping.ignore_malformed 全局设置,以允许在所有映射类型中全局忽略格式错误的内容(格式错误的内容示例正在尝试将字符串值索引为数字类型).

The index.mapping.ignore_malformed global setting can be set on the index level to allow to ignore malformed content globally across all mapping types (malformed content example is trying to index a string value as a numeric type).

编辑编辑了上面的URL,以跳转到新信息.

EDIT Edited the URL above to jump to the new information.

编辑再次编辑上面的URL以跳转到新信息.

EDIT Edited the URL above again to jump to the new information.

这篇关于Elasticsearch日期字段中的空字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆