code: @SuppressWarnings("unchecked")
      private boolean prepareMapping(String index, Map<String, Object> defaultMappings) {
          boolean success = true;
  
          for (Map.Entry<String, Object> stringObjectEntry : defaultMappings.entrySet()) {
              Map<String, Object> mapping = (Map<String, Object>) stringObjectEntry.getValue();
              if (mapping == null) {
                  throw new RuntimeException("type mapping not defined");
              }
              PutMappingRequestBuilder putMappingRequestBuilder = client.admin().indices().preparePutMapping()
                      .setIndices(index);
              putMappingRequestBuilder.setType(stringObjectEntry.getKey());
              putMappingRequestBuilder.setSource(mapping);
  
              if (log.isLoggable(Level.FINE)) {
                  log.fine("Elasticsearch create mapping for index '"
                          + index + " and type '" + stringObjectEntry.getKey() + "': " + mapping);
              }
  
              PutMappingResponse resp = putMappingRequestBuilder.execute().actionGet();
  
              if (resp.isAcknowledged()) {
                  if (log.isLoggable(Level.FINE)) {
                      log.fine("Elasticsearch mapping for index '"
                              + index + " and type '" + stringObjectEntry.getKey() + "' was acknowledged");
                  }
              } else {
                  success = false;
                  log.warning("Elasticsearch mapping creation was not acknowledged for index '"
                          + index + " and type '" + stringObjectEntry.getKey() + "'");
              }
          }
  
          return success;
      }
docs: This method applies the supplied mapping to the index.
  
  @param index The name of the index
  @param defaultMappings The default mappings
  @return true if the mapping was successful