Create index with org.elasticsearch.client

How do I use the org.elasticsearch.client.* to create an ES index? Do I need to, or can I name theme with * in their names and have them automatically created by ES?

I'm using Flink + Elasticsearch to stream data into the ES index. However, I'm indexing geopoints, and have would like to split all inserts into index-per-day. So I'm trying to do something like this:

import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.Requests;

// ...

HashSet<Date> haveRun = new HashSet<>(2);
Consumer<Date> checkIndex = (Date date) -> {
            if (haveRun.contains(date)) return;

            IndicesExistsRequest req = Requests.indicesExistsRequest(String.format("sessions_{}", date));
            // SOMETHING

to be called on every event. But I'm having trouble finding docs for how to do it? (The //SOMETHING part)

Also, can I do this in some better manner? It's pretty unclear IMO, when the request actually fires.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.