# Custom \_id modification in elastic search

**URL:** <https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514>\
**Category:** Elasticsearch\
**Created:** [March 1, 2024, 6:57am UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514 "2024-03-01T06:57:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweta04](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sweta04/32/122022_2.png) [@sweta04](https://discuss.elastic.co/u/sweta04)\
**Post date:** [March 1, 2024, 6:57am UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/1 "2024-03-01T06:57:46Z")

</div>

I want to set “\_id” value in Elasticsearch document as my custom document id,  
using this from kibana?  
POST example/\_doc  
{  
"\_id":123,  
"firstName":"Sera",  
"lastName":"Zuck"  
}  
for this what i need to do ? should i have to modify the source code or should i have to include something else in connector?

my elastic-connector-config file is this:

```auto
 {
 "name": "elastic-sink-connector",
  "config": {
    "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkCon>
    "tasks.max": "1",
    "topics": "test_topic",
    "connection.url": "http://localhost:9200",
    "key.ignore": "false",
    "schema.ignore": "true",
    "type.name": "_doc",
    "key.converter": "org.apache.kafka.connect.json.JsonConverter",
    "key.converter.schemas.enable": "false",
    "value.converter": "org.apache.kafka.connect.json.JsonConverter",
    "value.converter.schemas.enable": "false"
  }
}

```

PS: i dont want the \_id feild to be autogenerated, i want to pass it as request. I am working with confluent 7.6.0, elasticSearch 8.12.2 , kibana 8.12.2

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 1, 2024, 7:21am UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/2 "2024-03-01T07:21:00Z")

</div>

Welcome!

It should be something like:

```
PUT example/_doc/123
{
  "firstName":"Sera",
  "lastName":"Zuck"
}

```

---

<div class="post-metadata">

**Author:** ![sweta04](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sweta04/32/122022_2.png) [@sweta04](https://discuss.elastic.co/u/sweta04)\
**Post date:** [March 1, 2024, 7:43am UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/3 "2024-03-01T07:43:57Z")

</div>

Hi @dadoonet  
Thank you for your response.  
I wanted to seek clarification regarding the use of `/_doc/something`. Our current connector seems to require a different format, and I want to make sure I'm not missing any crucial details.  
Could you please provide additional information or guide me on the preferred format for our connector?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 1, 2024, 9:01am UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/4 "2024-03-01T09:01:21Z")

</div>

I don't know as this is not made by us.  
I guess you always could use in the worse case an ingest pipeline to modify your documents on the fly.

---

<div class="post-metadata">

**Author:** ![rtwolfe94022](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rtwolfe94022/32/132253_2.png) [@rtwolfe94022](https://discuss.elastic.co/u/rtwolfe94022)\
**Post date:** [March 1, 2024, 6:20pm UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/5 "2024-03-01T18:20:51Z")

</div>

You don't need to modify the source code or add anything extra to the connector. Just ensure your Kafka message key contains the custom `_id` you want for your Elasticsearch document. The connector configuration you provided is already set up to use the Kafka message key as the Elasticsearch document `_id` with `"key.ignore": "false"` . Make sure your Kafka messages are produced with the correct key that represents your custom `_id` .

---

<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 29, 2024, 6:20pm UTC](https://discuss.elastic.co/t/custom-id-modification-in-elastic-search/354514/6 "2024-03-29T18:20:51Z")

</div>

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