Upgrade 5.2 > 6.x

Hi,

When I try to update my project in ELS 1.6. I am encountering a problem :

IllegalArgumentException("mapping source must be pairs of fieldnames and properties definition.");

I try something easy as describe on https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin-indices.html#java-admin-indices-create-index

   public void createIndexBasic() {
         TransportClient transportClient = getClient();
         AdminClient adminClient = transportClient.admin();
         IndicesAdminClient indicesAdminClient = adminClient.indices();
         
         
         try {
                logger.info("deleteIndex");
                DeleteIndexResponse deleteIndexResponse = deleteDataByIndex("twitter");
                logger.info("delete Index before mapping " + deleteIndexResponse.toString());
         } catch (IndexNotFoundException e) {
                logger.error("Index non trouve");
         }            
         
         
         String mapping = "{\n" +                
            "    \"tweet\": {\n" +
            "      \"properties\": {\n" +
            "        \"message\": {\n" +
            "          \"type\": \"text\"\n" +
            "        }\n" +
            "      }\n" +
            "    }\n" +
            "  }";
         
         
         indicesAdminClient.prepareCreate("twitter")
         .addMapping("tweet", mapping )
           .get();      
         
   }

It seems mapping content has change. In V5, we could use json data :

/**
* A specialized simplified mapping source method, takes the form of simple properties definition:
* ("field1", "type=string,store=true").
*/
public CreateIndexRequestBuilder addMapping(String type, String source) {
request.mapping(type, source);
return this;
}

But now :

/**
* A specialized simplified mapping source method, takes the form of simple properties definition:
* ("field1", "type=string,store=true").
*/
public CreateIndexRequest mapping(String type, Object... source) {
mapping(type, **tMappingRequest.buildFromSimplifiedDef(type, source));
return this;
}

What's the way to put a json mapping to .mapping() function ?

Best regards

Philippe

as i know , 1 step update to 5.6.x 2 step update to 6.x

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.