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

 ##########
 File path: 
elasticsearch/rest/src/test/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContexFactoryIT.java
 ##########
 @@ -18,114 +18,122 @@
  */
 package org.apache.metamodel.elasticsearch.rest;
 
+import static 
org.apache.metamodel.elasticsearch.rest.ElasticSearchRestDataContext.DEFAULT_TABLE_NAME;
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.junit.Assert.*;
 
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.http.HttpHost;
 import org.apache.metamodel.BatchUpdateScript;
 import org.apache.metamodel.UpdateCallback;
 import org.apache.metamodel.data.DataSet;
 import org.apache.metamodel.data.Row;
+import org.apache.metamodel.elasticsearch.common.ElasticSearchUtils;
 import org.apache.metamodel.factory.DataContextFactory;
 import org.apache.metamodel.factory.DataContextPropertiesImpl;
 import org.apache.metamodel.schema.Column;
 import org.apache.metamodel.schema.ColumnType;
-import org.elasticsearch.action.index.IndexRequest;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.MutableTable;
+import org.apache.metamodel.schema.TableType;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
+import org.elasticsearch.client.RequestOptions;
 import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.PutMappingRequest;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 public class ElasticSearchRestDataContexFactoryIT {
     private static final String INDEX_NAME = "myindex";
 
-    private static ElasticSearchRestClient externalClient;
+    private static RestHighLevelClient externalClient;
 
     private String dockerHostAddress;
 
     private DataContextFactory factory;
+    
+    private DataContextPropertiesImpl properties;
 
     @Before
     public void setUp() throws Exception {
         dockerHostAddress = ElasticSearchRestDataContextIT.determineHostName();
 
-        externalClient = new ElasticSearchRestClient(RestClient.builder(new 
HttpHost(dockerHostAddress, 9200)).build());
+        externalClient = new RestHighLevelClient(RestClient
+                .builder(new HttpHost(dockerHostAddress, 
ElasticSearchRestDataContextIT.DEFAULT_REST_CLIENT_PORT)));
+        externalClient.indices().create(new CreateIndexRequest(INDEX_NAME), 
RequestOptions.DEFAULT);
 
-        final Map<String, Object> source = new LinkedHashMap<>();
-        source.put("mytext", "dummy");
+        final PutMappingRequest putMappingRequest = new 
PutMappingRequest(INDEX_NAME);
+        putMappingRequest
+                .source(ElasticSearchUtils
+                        .getMappingSource(new MutableTable(DEFAULT_TABLE_NAME, 
TableType.TABLE, new MutableSchema(
+                                INDEX_NAME), new MutableColumn("name", 
ColumnType.STRING), new MutableColumn("age",
+                                        ColumnType.INTEGER))));
 
 Review comment:
   More of these odd formattings. It kinda looks like it's broken up in the 
wrong order:
   - "Oh, there's no space for .source, BREAK IT UP."
   - "Oh, there's no space for .getMappingSource, BREAK IT UP."
   - "Oh look, now there's space for .source again. Nah, I'll leave it there."
   
   Oh well, maybe it's how it's supposed to be, but it sure looks weird.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to