code: public void createMapping(String indexName, String mappingName, ArrayList<XContentBuilder> mappingSource) {
          IndicesExistsResponse existsResponse = this.client.admin().indices().prepareExists(indexName).execute()
                  .actionGet();
          //If the index does not exists, it will be created without options
          if (!existsResponse.isExists()) {
              if (!createSingleIndex(indexName)) {
                  throw new ElasticsearchException("Failed to create " + indexName
                          + " index.");
              }
          }
          BulkRequestBuilder bulkRequest = this.client.prepareBulk();
          for (int i = 0; i < mappingSource.size(); i++) {
              int aux = i + 1;
  
              IndexRequestBuilder res = this.client
                      .prepareIndex(indexName, mappingName, String.valueOf(aux)).setSource(mappingSource.get(i));
              bulkRequest.add(res);
          }
          bulkRequest.execute();
      }
docs: Create a mapping over an index
  
  @param indexName
  @param mappingName
  @param mappingSource the data that has to be inserted in the mapping.