Github user cjolif commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6043#discussion_r190364900
  
    --- Diff: 
flink-connectors/flink-connector-elasticsearch-base/src/main/java/org/apache/flink/streaming/connectors/elasticsearch/RequestIndexer.java
 ---
    @@ -21,18 +21,56 @@
     import org.apache.flink.annotation.PublicEvolving;
     
     import org.elasticsearch.action.ActionRequest;
    +import org.elasticsearch.action.delete.DeleteRequest;
    +import org.elasticsearch.action.index.IndexRequest;
    +import org.elasticsearch.action.update.UpdateRequest;
     
     /**
    - * Users add multiple {@link ActionRequest ActionRequests} to a {@link 
RequestIndexer} to prepare
    + * Users add multiple delete, index or update requests to a {@link 
RequestIndexer} to prepare
      * them for sending to an Elasticsearch cluster.
      */
     @PublicEvolving
    -public interface RequestIndexer {
    +public abstract class RequestIndexer {
     
        /**
         * Add multiple {@link ActionRequest} to the indexer to prepare for 
sending requests to Elasticsearch.
         *
         * @param actionRequests The multiple {@link ActionRequest} to add.
    +    * @deprecated use the {@link DeleteRequest}, {@link IndexRequest} or 
{@Up}
         */
    -   void add(ActionRequest... actionRequests);
    +   @Deprecated
    +   public void add(ActionRequest... actionRequests) {
    +           for (ActionRequest actionRequest : actionRequests) {
    +                   if (actionRequest instanceof IndexRequest) {
    +                           add((IndexRequest) actionRequest);
    +                   } else if (actionRequest instanceof DeleteRequest) {
    +                           add((DeleteRequest) actionRequest);
    +                   } else if (actionRequest instanceof UpdateRequest) {
    +                           add((UpdateRequest) actionRequest);
    +                   } else {
    +                           throw new 
IllegalArgumentException("RequestIndexer only supports Index, Delete and Update 
requests");
    +                   }
    +           }
    +   }
    +
    +   /**
    +    * Add multiple {@link DeleteRequest} to the indexer to prepare for 
sending requests to Elasticsearch.
    +    *
    +    * @param deleteRequests The multiple {@link DeleteRequest} to add.
    +    */
    +   public abstract void add(DeleteRequest... deleteRequests);
    --- End diff --
    
    I would say that we can finally hope that Elasticsearch, with promoting the 
new REST API, will have finished for quite some time breaking APIs. Also 
obviously having our own API would be one more thing for the user to learn 
(instead of just using the raw ES API) and one more object we would create for 
each request (I guess negligible but still if that is not a big gain, why doing 
it?). And finally, less intermediary layer is less risk of bug from my point of 
view (and as so as you said less maintenance work).
    
    More generally I tend to always prefer less code than more code except when 
more code is definitely the way to go and here I'm not convinced. That said I 
can't indeed promise Elasticsearch won't break API again... So if people want 
that intermediary object I can try to look into it. 
    
    Anyone else having opinion? :) 



---

Reply via email to