弹性搜索中的商店日期格式 [英] Store Date Format in elasticsearch

查看:130
本文介绍了弹性搜索中的商店日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



该文件如下:



我遇到一个问题,当我想添加一个datetime字符串到Elasticsearch。

  {LastUpdate:2013/07/24 00:00:00} 

此文件引发了一个错误,它是NumberFormatException[对于输入字符串:\20130724 00:00:00\]



我知道我可以使用Elasticsearch中的日期格式,但即使我在网站上阅读文档也不知道如何使用。

  {LastUpdate:{
properties:{
type:date,
格式:yyyy-MM-dd}
}
}

  {LastUpdate:{
type:date,
format :yyyy-MM-dd
}
}



如何将日期时间字符串转换为Elasticsearch中的日期格式?



如何存储日期时间字符串可怕ctly into Elasticsearch?

解决方案

你几乎在那里。设置这样的映射:

  {LastUpdate:{
type:date,
格式:yyyy / MM / dd HH:mm:ss}
}

阅读日期映射和其选项日期格式参数(日期映射的选项之一)。



祝你好运!


I met a problem when I want to add one datetime string into Elasticsearch.

The document is below:

{"LastUpdate" : "2013/07/24 00:00:00"}

This document raised an error which is "NumberFormatException" [For input string: \"20130724 00:00:00\"]

I know that I can use the Date Format in Elasticsearch, but I don't know how to use even I read the document on the website.

{"LastUpdate": {
    "properties": {
        "type": "date", 
        "format": "yyyy-MM-dd"}
    }
}

and

{"LastUpdate": {
    "type": "date", 
    "format": "yyyy-MM-dd"
    }
}

are wrong.

How can I transfer the datetime string into date format in Elasticsearch?

How can I store the datetime string directly into Elasticsearch?

解决方案

You are nearly there. Set your mapping like this:

{"LastUpdate": {
    "type" : "date",
    "format" : "yyyy/MM/dd HH:mm:ss"}
}

Read the docs on the date mapping and its options and the date format parameter (one of the options to the date mapping).

Good luck!

这篇关于弹性搜索中的商店日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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