# Create index with org.elasticsearch.client

**URL:** <https://discuss.elastic.co/t/create-index-with-org-elasticsearch-client/175842>\
**Category:** Elasticsearch\
**Created:** [April 8, 2019, 12:47pm UTC](https://discuss.elastic.co/t/create-index-with-org-elasticsearch-client/175842 "2019-04-08T12:47:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haf/32/43669_2.png) [@haf](https://discuss.elastic.co/u/haf)\
**Post date:** [April 8, 2019, 12:47pm UTC](https://discuss.elastic.co/t/create-index-with-org-elasticsearch-client/175842/1 "2019-04-08T12:47:12Z")

</div>

**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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 6, 2019, 12:47pm UTC](https://discuss.elastic.co/t/create-index-with-org-elasticsearch-client/175842/2 "2019-05-06T12:47:16Z")

</div>

Closed on May 6, 2019, 12:47pm UTC

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