arjansh commented on a change in pull request #229: Upgrade to Elasticsearch 
7.3.1
URL: https://github.com/apache/metamodel/pull/229#discussion_r338923327
 
 

 ##########
 File path: 
elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestUpdateCallback.java
 ##########
 @@ -135,20 +140,32 @@ public void execute(final ActionRequest action) {
 
     private void executeBlocking(final ActionRequest action) {
         try {
-            if (action instanceof PutMappingRequest) {
-                
getDataContext().getElasticSearchClient().createMapping((PutMappingRequest) 
action);
+            final RestHighLevelClient client = 
getDataContext().getRestHighLevelClient();
+            final ActionResponse result;
+
+            if (action instanceof BulkRequest) {
+                result = client.bulk((BulkRequest) action, 
RequestOptions.DEFAULT);
+            } else if (action instanceof IndexRequest) {
+                result = client.index((IndexRequest) action, 
RequestOptions.DEFAULT);
+            } else if (action instanceof DeleteRequest) {
+                result = client.delete((DeleteRequest) action, 
RequestOptions.DEFAULT);
+            } else if (action instanceof ClearScrollRequest) {
+                result = client.clearScroll((ClearScrollRequest) action, 
RequestOptions.DEFAULT);
+            } else if (action instanceof SearchScrollRequest) {
+                result = client.scroll((SearchScrollRequest) action, 
RequestOptions.DEFAULT);
 
 Review comment:
   I think introducing an adapter is going one step to far here, but I will 
extract the "if ... else if ..." part into a separate method, which make it a 
little more readable, at least it separates the "doing the right invocation on 
the client" part from the rest of the logic in this method.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to