简体   繁体   English

如何将数据从风暴导出到弹性搜索?

[英]How to export data from storm to elastic search?

I stored my data into Apache Kafka. 我将数据存储到Apache Kafka中。 Then I able to use the data using Apache Storm spout and I processed the data. 然后,我可以使用Apache Storm喷口使用数据,并处理了数据。 Now I want to export processed data into elastic search. 现在,我想将处理后的数据导出到弹性搜索中。

ElasticSearch provides Java client api available in maven repository. ElasticSearch提供了Maven存储库中可用的Java客户端api。

If you already implemented pulling data from kafka to storm, all you have to do is implement one bolt that sends indexing request of that log to the elastic search. 如果您已经实现了从kafka到Storm的数据提取,您要做的就是实现一个螺栓,该螺栓将日志的索引请求发送到弹性搜索。

Here I'm talking in traditional topology perspective. 在这里,我从传统的拓扑角度进行讨论。

For example, in your prepare method implementation, you create a transport client like this. 例如,在您的prepare方法实现中,您将像这样创建一个传输客户端。

Client client = new TransportClient()
    .addTransportAddress(new InetSocketTransportAddress("host1", 9300))
    .addTransportAddress(new InetSocketTransportAddress("host2", 9300));

And in your execute method implementation, you send indexing request like this. 在执行方法的实现中,您将像这样发送索引请求。

String json = "{" +
    "\"user\":\"kimchy\"," +
    "\"postDate\":\"2013-01-30\"," +
    "\"message\":\"trying out Elasticsearch\"" +
"}";

IndexResponse response = client.prepareIndex("twitter", "tweet")
    .setSource(json)
    .execute()
    .actionGet();

For more information, refer to http://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html . 有关更多信息,请参阅http://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html

You can use ES Storm integration: 您可以使用ES Storm集成:

https://www.elastic.co/guide/en/elasticsearch/hadoop/current/storm.html https://www.elastic.co/guide/zh-CN/elasticsearch/hadoop/current/storm.html

Or write back your data into Kafka and use LogStash to consume this queue and write to elasticsearch. 或者将您的数据写回Kafka,并使用LogStash消耗此队列并写入elasticsearch。

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

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