简体   繁体   English

Elasticsearch-py 日期格式错误

[英]Elasticsearch-py date malformed

I am trying to index some data but I keep getting the error我正在尝试索引一些数据,但我不断收到错误消息

error: reason: failed to parse [date] type: mapper_parsing_exception, caused_by: Invalid format: 2016-08-12\t17:35:26 is malformed at \t17:35:26

My mapping looks like我的映射看起来像

'date': { 'type': 'date', 'format': 'dateOptionalTime' },

Is there a different way to create the date mapping?有没有不同的方法来创建日期映射?

EDIT: Here is a line from the document.编辑:这是文档中的一行。 I can get it to index just fine when I set time to string and date to date but the date shows a bogus time attached to it.当我将时间设置为字符串并将日期设置为日期时,我可以让它很好地索引,但日期显示附加到它的虚假时间。 So it looks like ES is taking my date (2016/9/20) and adding a time to it.所以看起来 ES 正在接受我的约会 (2016/9/20) 并为其添加时间。 In my case it adds 19:00:00.就我而言,它增加了 19:00:00。 Which is why I can't figure out why it doesnt like the time.这就是为什么我不明白为什么它不喜欢时间。

2016-06-14  18:12:35    1.1.1.1 GET /origin-www.origin.com/Images/pipe-gray.png?    200 1442    0   "http://www.origin.com/Main.css"    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36" "__qca=P0-920525163; s_fid=4CDFF16906A35CC4; __CSCookie=z5ayStQYdIbcPTxGKyhsjRIi0peP5GAP6K; icxid=1459286804904; icxid=1459286804904; ASP.NET_SessionId=dzg3esjzp4tpg; __SessionCookie=gXA9BuDiF245ZJeuh; dtCookie=0C05828501CE759D; s_vi=[CS]v1|2A069D04051D2E2A; __CSUserIbcIDCookie=NL7VeN+rh05z5FWSCgTnzTC6G;"

Before adding the date to hashtable or before u feed it to json, convert the date "2016-02-10\\t10:25:30" to this "2016-02-10T10:25:30"在将日期添加到哈希表或将其提供给 json 之前,将日期“2016-02-10\\t10:25:30”转换为“2016-02-10T10:25:30”

If you give elasticsearch this format, you should be able to use the original mapping - dateOptionalTime.如果你给elasticsearch这个格式,你应该能够使用原始映射-dateOptionalTime。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM