# Does the java new client support \_doc api?

**URL:** <https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444>\
**Category:** Elasticsearch\
**Created:** [February 17, 2022, 7:16am UTC](https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444 "2022-02-17T07:16:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkskrkwrr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkskrkwrr/32/101909_2.png) [@dkskrkwrr](https://discuss.elastic.co/u/dkskrkwrr)\
**Post date:** [February 17, 2022, 7:16am UTC](https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444/1 "2022-02-17T07:16:27Z")

</div>

Hello, we are migrating from the Java Rest High Level Client to the New Rest Client.  
Currently, the java new rest client seems to support document create EndPoint only with \_create.  
I'm going to use \_doc Endpoint to automatically specify the id of the document, but is there any way to create a document through that endpoint now or is there any additional plan in the fucure?

here is code sample  
OK

```auto
CreateRequest createRequest = new CreateRequest.Builder<T>()
					.index(targetIndex)
					.id(indexId)
					.document(document)
					.build();
client.create(createRequest);

```

Endpoint is \_create Failed

```auto
CreateRequest createRequest = new CreateRequest.Builder<T>()
					.index(targetIndex)
					.document(document)
					.build();
client.create(createRequest);

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 17, 2022, 8:58am UTC](https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444/2 "2022-02-17T08:58:35Z")

</div>

Hey,

I am not sure what you mean with `_doc` endpoint. Can you clarify? If you do not want to create an ID, you can go with the IndexRequest instead, that generates an ID. Would that work for you?

If you think this feature should be added, please create an issue in [GitHub - elastic/elasticsearch-java: Official Elasticsearch Java Client](https://github.com/elastic/elasticsearch-java)

--Alex

---

<div class="post-metadata">

**Author:** ![dkskrkwrr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkskrkwrr/32/101909_2.png) [@dkskrkwrr](https://discuss.elastic.co/u/dkskrkwrr)\
**Post date:** [February 21, 2022, 1:31am UTC](https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444/3 "2022-02-21T01:31:00Z")

</div>

Thank you for your answer.  
I thought IndexRequest was a class that only manages simple indexes.  
I solved it in that way. Thank you.

---

<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:** [March 21, 2022, 1:31am UTC](https://discuss.elastic.co/t/does-the-java-new-client-support-doc-api/297444/4 "2022-03-21T01:31:43Z")

</div>

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