elasticsearch - NiFi/ElasticSearch:日期无法解析

标签 elasticsearch apache-nifi

我正在使用NiFi将一些数据放入ElasticSearch。我创建了以下ES索引:

curl -XPUT http://localhost:9200/test_index -H 'Content-Type: application/json' -d'
{
"index_patterns" : ["test_index"],
"mappings" : {
    "doc"  : {
        "properties" : {
            "example1" :  { "type": "text" },
            "example2" :     { "type": "text" },
            "Date" :         
                { "type": "date",
                  "format": "yyyy-MM-dd HH:mm:ss" }
            }
        }
    }
}'

这加载到ES,没问题。但是,通过我的NiFi流传来的Date对象是这样的:
"Date" : "Fri, 09 Nov 2018 18:30:49 GMT"

我的PutElasticsearchHttp处理器给我一个错误:
ERROR [Timer-Driven Process Thread-1] o.a.n.p.e.PutElasticsearchHttp 
PutElasticsearchHttp[id=55b31b9a-3319-124c-4ede-0d3e8c02e9cb] Failed to 
process StandardFlowFileRecord[uuid=5b6d8fc7-0dfd-435d-8a5c- 
adb4cdb08495,claim=StandardContentClaim 
[resourceClaim=StandardResourceClaim[id=1541788260542-269, 
container=default, section=269], offset=176034, 
length=187],offset=0,name=ba74c484-9719-418f-a665- 
7b7d492b40a4,size=187] due to failed to parse [Date], transferring to 
failure

我需要更改日期格式吗? (也许通过UpdateAttribute吗?)

最佳答案

是的,您需要将nifi中的日期设置为更常见的格式,例如https://en.wikipedia.org/wiki/ISO_8601或在es映射中设置自定义日期格式。

请查看此处描述的模式:https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html

如果您需要了解如何在es中定义自定义日期映射,请查看以下内容:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

关于elasticsearch - NiFi/ElasticSearch:日期无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53232042/

相关文章:

elasticsearch - 如何标记从 Neo4j 复制到 Elastic 搜索的数据?

json - nifi invokehttp post复杂的json

hive - 带有Hive 1.1(CDH 5.7.1)的Apache NiFi Hive处理器

json - 在 Nifi 中从 Avro Schema 创建 Postgresql 表

elasticsearch - 分词器与分词过滤器

elasticsearch - titan- elasticseach和com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex

elasticsearch - 如何列出 Elasticsearch 集群上所有存储的脚本?

types - 限制 Percolator 调用 ElasticSearch 中的类型

java - SparkLauncher 使用yarn-client运行spark-submit,用户作为hive

mysql - 在 NiFi 中使用 ConvertRecord 处理 Null