public void createIndex(String index, boolean ignoreErrors, String indexSettings) throws IOException {
        logger.debug("create index [{}]", index);
        logger.trace("index settings: [{}]", indexSettings);
        CreateIndexRequest cir = new CreateIndexRequest(index);
        if (!isNullOrEmpty(indexSettings)) {
            cir.source(indexSettings, XContentType.JSON);
        }
        try {
            client.indices().create(cir, RequestOptions.DEFAULT);
        } catch (ElasticsearchStatusException e) {
            if (e.getMessage().contains("resource_already_exists_exception") && !ignoreErrors) {
                throw new RuntimeException("index already exists");
            }
            if (!e.getMessage().contains("resource_already_exists_exception")) {
                throw e;
            }
        }
        waitForHealthyIndex(index);
    }
public void createIndex ( String index , boolean ignoreErrors , String indexSettings ) throws IOException { logger . debug ( "create index [{}]" , index ) ; logger . trace ( "index settings: [{}]" , indexSettings ) ; CreateIndexRequest cir = new CreateIndexRequest ( index ) ; if ( ! isNullOrEmpty ( indexSettings ) ) { cir . source ( indexSettings , XContentType . JSON ) ; } try { client . indices ( ) . create ( cir , RequestOptions . DEFAULT ) ; } catch ( ElasticsearchStatusException e ) { if ( e . getMessage ( ) . contains ( "resource_already_exists_exception" ) && ! ignoreErrors ) { throw new RuntimeException ( "index already exists" ) ; } if ( ! e . getMessage ( ) . contains ( "resource_already_exists_exception" ) ) { throw e ; } } waitForHealthyIndex ( index ) ; }
Create an index
@param index index name
@param ignoreErrors don't fail if the index already exists
@param indexSettings index settings if any
@throws IOException In case of error