elasticsearch,apache-flink,Java,elasticsearch,Apache Flink" /> elasticsearch,apache-flink,Java,elasticsearch,Apache Flink" />

Java flink如何使用shield插件验证弹性搜索接收器

Java flink如何使用shield插件验证弹性搜索接收器,java,elasticsearch,apache-flink,Java,elasticsearch,Apache Flink,弹性搜索版本:2.3.3 Flink版本:1.1.3 为了设置ElasticSearchSink,我将配置数据的映射注入ElasticSearchSink。然后,传输客户机使用此连接 因为我的Elastic搜索服务器有一个Shield插件,我们需要进行身份验证,但是在flink文档中没有提到如何进行身份验证 我确实在elastic search网站上找到了: 它在配置中有一个选项“shield.user”,所以我在HashMap中添加了这个配置选项 Map<String, String&g

弹性搜索版本:2.3.3

Flink版本:1.1.3

为了设置ElasticSearchSink,我将配置数据的映射注入ElasticSearchSink。然后,传输客户机使用此连接

因为我的Elastic搜索服务器有一个Shield插件,我们需要进行身份验证,但是在flink文档中没有提到如何进行身份验证

我确实在elastic search网站上找到了:

它在配置中有一个选项“shield.user”,所以我在HashMap中添加了这个配置选项

Map<String, String> config = new HashMap<>();
// This instructs the sink to emit after every element, otherwise they would be buffered
config.put("bulk.flush.max.actions", "1");
config.put("cluster.name", "my-cluster-name");
config.put("shield.user", "username:password"); //<----ES Auth here

List<InetSocketAddress> transports = new ArrayList<>();
transports.add(new InetSocketAddress(InetAddress.getByName("172.19.1.57"), 9300));

input.addSink(new ElasticsearchSink(config, transports, new ElasticsearchSinkFunction<String>() {
  public IndexRequest createIndexRequest(String element) {
    Map<String, String> json = new HashMap<>();
    json.put("data", element);

    return Requests.indexRequest()
            .index("my-index")
            .type("my-type")
            .source(json);
  }

  @Override
  public void process(String element, RuntimeContext ctx, RequestIndexer indexer) {
    indexer.add(createIndexRequest(element));
  }
}));
我传递的凭据与http api使用的凭据相同,因此我假设它们应该可以工作。我还根据文档将该用户添加到transport_客户端角色

更新:连接失败的原因是我需要在pom.xml中添加对shield插件的依赖性:

<repository>
    <id>elasticsearch-releases</id>
    <url>https://maven.elasticsearch.org/releases</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>shield</artifactId>
    <version>2.3.3</version>
</dependency>

弹性搜索释放
https://maven.elasticsearch.org/releases
真的
假的
org.elasticsearch.plugin
盾
2.3.3
我仍然需要让传输客户端知道如何使用插件。TransportClient中的静态生成器类中有一个公共函数“addPlugin”,但该对象是弹性搜索接收器中的私有成员,我不确定如何访问该函数


有什么想法吗?

请打开一个改进bug,以便调整接收器的插件。
<repository>
    <id>elasticsearch-releases</id>
    <url>https://maven.elasticsearch.org/releases</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>shield</artifactId>
    <version>2.3.3</version>
</dependency>