# High level rest client with data stream

**URL:** <https://discuss.elastic.co/t/high-level-rest-client-with-data-stream/276828>\
**Category:** Elasticsearch\
**Tags:** language-clients, datastreams\
**Created:** [June 23, 2021, 5:21pm UTC](https://discuss.elastic.co/t/high-level-rest-client-with-data-stream/276828 "2021-06-23T17:21:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prithvirajsivarajan](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@prithvirajsivarajan](https://discuss.elastic.co/u/prithvirajsivarajan)\
**Post date:** [June 23, 2021, 5:21pm UTC](https://discuss.elastic.co/t/high-level-rest-client-with-data-stream/276828/1 "2021-06-23T17:21:25Z")

</div>

I'm using high level rest client to bulk insert data. In the BulkRequest object, we are inserting the data with the 'index' operation. like this:

```auto
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "field1" : "value1" }

```

But in data stream, we have to use 'create' operation. like this,

```auto
{"create":{ }}
{ "@timestamp": "2099-03-08T11:04:05.000Z", "user": { "id": "vlb44hny" }, "message": "Login attempt failed" }

```

Is there an option where I could tell my rest client to use 'create' instead of 'index'?

Or is there a work around to insert the docs with 'index' op?

How exactly 'create' and 'index' operations differ from each other and why data stream need to use 'create' opration

---

<div class="post-metadata">

**Author:** ![joecwu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joecwu/32/37258_2.png) [@joecwu](https://discuss.elastic.co/u/joecwu)\
**Post date:** [June 24, 2021, 1:06am UTC](https://discuss.elastic.co/t/high-level-rest-client-with-data-stream/276828/2 "2021-06-24T01:06:57Z")

</div>

I'm not sure what kind of rest client are you using.

In Java rest client, you can set the `OpType` to `OpType.CREATE` in `IndexRequest` object and BulkRequest should generate `create` operation instead of `index`.

Because the DataStream has its own logic to maintain the index rollover and that is why you should not specify the index name during the document indexing on DataStream.

---

<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:** [July 22, 2021, 1:07am UTC](https://discuss.elastic.co/t/high-level-rest-client-with-data-stream/276828/3 "2021-07-22T01:07:26Z")

</div>

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