code: private static boolean isMappingExist(RestHighLevelClient client, String index) throws Exception {
          GetMappingsResponse mapping = client.indices().getMapping(new GetMappingsRequest().indices(index), RequestOptions.DEFAULT);
          // Let's get the default mapping
          if (mapping.mappings().isEmpty()) {
              return false;
          }
          MappingMetaData doc = mapping.mappings().values().iterator().next();
          return !doc.getSourceAsMap().isEmpty();
      }
docs: Check if an index already exist
  @param client Elasticsearch client
  @param index Index name
  @return true if the index already exist
  @throws Exception if the elasticsearch call is failing