@BeforeClass public static void setup() throws Exception { esSetup = new EsSetup(); esSetup.execute(EsSetup.deleteAll()); esSetup.execute(EsSetup .createIndex(EventElasticSearchIO.EVENT_INDEX) .withMapping(EventElasticSearchIO.ES_TYPE, EsSetup.fromClassPath("events_mapping.json"))); searchIO = new EventElasticSearchIO(); createTestEvents(TENANT_1, TENANT_1_EVENTS_NUM); createTestEvents(TENANT_2, TENANT_2_EVENTS_NUM); createTestEvents(TENANT_WITH_SYMBOLS, TENANT_WITH_SYMBOLS_NUM); createRangeEvents(TENANT_RANGE, TENANT_RANGE_EVENTS_NUM, RANGE_STEP_IN_SECONDS); int statusCode = searchIO.elasticsearchRestHelper.refreshIndex(EventElasticSearchIO.EVENT_INDEX); if(statusCode != 200) { System.out.println(String.format("Refresh for %s failed with status code: %d", EventElasticSearchIO.EVENT_INDEX, statusCode)); } }
/** * Instantiates a request that can be used to create an index. * Here's a sample of how create an index: * <pre> * import static com.github.tlrx.elasticsearch.test.EsSetup.createIndex; * ... * createIndex("my_index") * .withSource(...) * </pre> * * @param index the index name * @return a {@link CreateIndex} request */ public static CreateIndex createIndex(String index) { return new CreateIndex(index); }
public CreateIndex withSettings(JSONProvider jsonProvider) { withSettings(jsonProvider.toJson()); return this; }
public CreateIndex withSettings(JSONProvider jsonProvider) { withSettings(jsonProvider.toJson()); return this; }
public CreateIndex withMapping(String type, JSONProvider jsonProvider) { withMapping(type, jsonProvider.toJson()); return this; }
public CreateIndex withSettings(String source) { Settings settings = ImmutableSettings.settingsBuilder() .loadFromSource(source) .build(); withSettings(settings); return this; }
/** * Instantiates a request that can be used to create an index. * Here's a sample of how create an index: * <pre> * import static com.github.tlrx.elasticsearch.test.EsSetup.createIndex; * ... * createIndex("my_index") * .withSource(...) * </pre> * * @param index the index name * @return a {@link CreateIndex} request */ public static CreateIndex createIndex(String index) { return new CreateIndex(index); }
public CreateIndex withMapping(String type, JSONProvider jsonProvider) { withMapping(type, jsonProvider.toJson()); return this; }
public CreateIndex withSettings(String source) { Settings settings = ImmutableSettings.settingsBuilder() .loadFromSource(source) .build(); withSettings(settings); return this; }