public GetIndexResponse getOrCreateIndex ( String indexParam ) { if ( this . doesIndexExist ( indexParam ) ) { return this . client . admin ( ) . indices ( ) . prepareGetIndex ( ) . get ( ) ; } else { CreateIndexRequestBuilder createIndexRequestBuilder = this . client . admin ( ) . indices ( ) . prepareCreate ( indexParam ) ; CreateIndexResponse mappingCreateResponse = createIndexRequestBuilder . execute ( ) . actionGet ( ) ; if ( ! mappingCreateResponse . isAcknowledged ( ) ) { throw new FluidElasticSearchException ( "Index Creation for '" + indexParam + "' not acknowledged by ElasticSearch." ) ; } return this . client . admin ( ) . indices ( ) . prepareGetIndex ( ) . get ( ) ; } }
Creates a new index or fetches existing index .