src/main/java/org/novus/es/client/ESClient.java
/**
   * Creates an index for the tenant name or index name inputed.
   *
   * @param indexName
   *          String
   * @param client
   *          TODO
   * @throws IOException
   */
Creates an index for the tenant name or index name inputed.
@param indexName
String
@param client
TODO
@throws IOException
Creates an index for the tenant name or index name inputed . @param indexName String @param client TODO @throws IOException
public static void loadSchema(final String indexName, TransportClient client, String schema)
      throws IOException {
    IndicesExistsResponse res = null;
    res = client.admin().indices().prepareExists(indexName).execute().actionGet();
    if (!res.isExists()) {
      final Settings indexSettings = Settings.builder().put("number_of_shards", 1).build();
      final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
      createIndexRequestBuilder.setSource(schema, XContentType.JSON).setSettings(indexSettings);
      createIndexRequestBuilder.execute().actionGet();
      client.admin().indices().prepareFlush().setForce(true).setWaitIfOngoing(true).execute().actionGet();
    }
  }
public static void loadSchema ( final String indexName , TransportClient client , String schema ) throws IOException { IndicesExistsResponse res = null ; res = client . admin ( ) . indices ( ) . prepareExists ( indexName ) . execute ( ) . actionGet ( ) ; if ( ! res . isExists ( ) ) { final Settings indexSettings = Settings . builder ( ) . put ( "number_of_shards" , 1 ) . build ( ) ; final CreateIndexRequestBuilder createIndexRequestBuilder = client . admin ( ) . indices ( ) . prepareCreate ( indexName ) ; createIndexRequestBuilder . setSource ( schema , XContentType . JSON ) . setSettings ( indexSettings ) ; createIndexRequestBuilder . execute ( ) . actionGet ( ) ; client . admin ( ) . indices ( ) . prepareFlush ( ) . setForce ( true ) . setWaitIfOngoing ( true ) . execute ( ) . actionGet ( ) ; } }
Creates an index for the tenant name or index name inputed.
Creates an index for the tenant name or index name inputed .