Github user cjolif commented on the issue:

    https://github.com/apache/flink/pull/6043
  
    @tzulitai 
    
    Happy to see progress is made on this!
    
    > After merging this, I'll also try cherry-picking your 6.x REST-based ES 
connector on top. If that works well, will also merge that.
    
    Note that since the initial ES PR (#5374 ) I made a couple of changes in 
our own copy of this. 
    
    1. Elasticsearch REST API can have a context root in addition the to list 
of httpHosts, so I added the ability to have prefixPath, and calling:
    
    ```java
        final RestClientBuilder builder = 
RestClient.builder(httpHosts.toArray(new HttpHost[httpHosts.size()]));
    
        if (pathPrefix != null && !pathPrefix.isEmpty() && 
!pathPrefix.equals("/")) {
          builder.setPathPrefix(this.pathPrefix);
        }
    ```
    
    So that is set on the builder.
    
    2. Elasticsearch REST can be protected by login/password so I added the 
ability to set username/password:
    
    ```java
      private CredentialsProvider getCredentialProvider() {
        CredentialsProvider credentialsProvider = null;
        if (userConfig.containsKey(CONFIG_KEY_ES_USERNAME) && 
userConfig.containsKey(CONFIG_KEY_ES_PASSWORD)) {
          credentialsProvider = new BasicCredentialsProvider();
          credentialsProvider.setCredentials(AuthScope.ANY,
              new 
UsernamePasswordCredentials(userConfig.get(CONFIG_KEY_ES_USERNAME), 
userConfig.get(CONFIG_KEY_ES_PASSWORD)));
        }
        return credentialsProvider;
      }
    ```
    and 
    then
    ```
            builder.setHttpClientConfigCallback(httpClientBuilder ->
                httpClientBuilder
                    .setDefaultCredentialsProvider(getCredentialProvider()))
    ```
    
    More generally it should be easy for the user to change how the builder is 
configure to make sure people can customize this as they want (like configure 
SSL...).


---

Reply via email to