protected void initializeIndices(RestHighLevelClient client, Map<String, EsIndexProperties> indexDefs, String indexPrefix) {
        try {
            //Do Health request
            ClusterHealthRequest healthRequest = new ClusterHealthRequest();
            try {
                client.cluster().health(healthRequest, RequestOptions.DEFAULT);
            } catch (IOException e) {
                logger.error("Health check failed - cannot connect to elasticsearch", e);
            }

            // There was occasions where a race occurred here when multiple threads try to
            // create the index simultaneously. This caused a non-fatal, but annoying, exception.
            synchronized (AbstractClientFactory.class) {
                for (Entry<String, EsIndexProperties> entry : indexDefs.entrySet()) {

                    String indexPostfix = entry.getKey();
                    EsIndexProperties index = entry.getValue();

                    String fullIndexName = EsIndexMapping.getFullIndexName(indexPrefix, indexPostfix);

                    if (!createdIndices.contains(fullIndexName)) {
                        GetIndexRequest indexExistsRequest = new GetIndexRequest(fullIndexName);
                        boolean indexExists = client.indices().exists(indexExistsRequest, RequestOptions.DEFAULT);
                        if (!indexExists) {
                            this.createIndex(client, index, indexPrefix, indexPostfix); //$NON-NLS-1$
                            createdIndices.add(fullIndexName);
                        }
                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
Called to initialize the storage.
@param client the es client
@param indexDefs the index definitions for the component being initialised (can be empty map)
@param indexPrefix the index prefix of the ES index to initialize
common/es/src/main/java/io/apiman/common/es/util/AbstractClientFactory.java