code: public boolean existsMapping(String indexName, String mappingName) {
          ClusterStateResponse resp = this.client.admin().cluster().prepareState().execute().actionGet();
  
          if (resp.getState().getMetaData().index(indexName) == null) {
              return false;
          }
          ImmutableOpenMap<String, MappingMetaData> mappings = resp.getState().getMetaData().index(indexName).getMappings();
  
          if (mappings.get(mappingName) != null) {
              return true;
          }
          return false;
      }
docs: Check if a mapping exists in an expecific index.
  
  @param indexName
  @param mappingName
  @return true if the mapping exists and false in other case