Apache NiFi:PutElasticSearchHttp不起作用,出现空白错误

时间:2018-03-15 21:12:24

标签: elasticsearch apache-nifi

我目前在同一台机器上运行Elasticsearch版本6.2.2和Apache Nifi版本1.5.0。我试图按照位于https://community.hortonworks.com/articles/52856/stream-data-into-hive-like-a-king-using-nifi.html的Nifi示例,除了不存储到Hive,我想存储到Elasticsearch。

最初我尝试使用PutElasticsearch5处理器,但我在Elasticsearch上收到以下错误:

Received message from unsupported version: [5.0.0] minimal compatible version is: [5.6.0]

当我尝试使用Google搜索此错误消息时,似乎共识是使用PutElasticsearchHttp处理器。我的Nifi看起来像: enter image description here

PutElasticsearchHttp处理器的配置: enter image description here

当流文件到达PutElasticsearchHttp处理器时,会出现以下错误:enter image description here

PutElasticSearchHttp failed to insert StandardFlowFileRecord into Elasticsearch due to , transferring to failure. 

似乎原因是空白/ null。 Elasticsearch日志中也没有任何内容。

在ConvertAvroToJson之后,数据是一个JSON数组,其中所有条目都在一行上。这是一个示例值:

{"City": "Athens", 
 "Edition": 1896, 
 "Sport": "Aquatics", 
 "sub_sport": "Swimming",
 "Athlete": "HAJOS, Alfred", 
 "country": "HUN", 
 "Gender": "Men", 
 "Event": "100m freestyle", 
 "Event_gender": "M", 
 "Medal": "Gold"}

有关如何调试/解决此问题的任何想法?我是否需要先在Elasticsearch中创建任何内容?我的配置是否正确?

3 个答案:

答案 0 :(得分:3)

我能够弄清楚。在ConvertAvroToJSON之后,流文件是一行包含JSON索引的JSON数组。由于我想存储各个索引,我需要一个SplitJSON处理器。现在我的Nifi看起来像这样:

Nifi flow with SplitJSON

SplitJson的配置如下所示:

Processor Details for SplitJSON

答案 1 :(得分:0)

索引名称不能包含/字符。尝试使用有效的索引名称:例如运动。

答案 2 :(得分:0)

我有一个类似的流程,其中包括_doc后,将类型更改为splitTojSON