# Elasticsearch bulk indexing the documents using Java API Client

**URL:** <https://discuss.elastic.co/t/elasticsearch-bulk-indexing-the-documents-using-java-api-client/356995>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [April 8, 2024, 4:05pm UTC](https://discuss.elastic.co/t/elasticsearch-bulk-indexing-the-documents-using-java-api-client/356995 "2024-04-08T16:05:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harsha\_kannan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsha_kannan/32/122040_2.png) [@harsha\_kannan](https://discuss.elastic.co/u/harsha_kannan)\
**Post date:** [April 8, 2024, 4:05pm UTC](https://discuss.elastic.co/t/elasticsearch-bulk-indexing-the-documents-using-java-api-client/356995/1 "2024-04-08T16:05:49Z")

</div>

0

I have inserted some documents into my index using ElasticsearchRepository's saveAll() method and Bulk Indexing method. When I tried fetching records using elasticSearchOperations and I see the fields name has changed in the documents which are bulk indexed. Example - the actual field name was "userName" and in the bulk indexed documents the field name was changed into "user\_name". I also noticed that in hits().source(), the "\_class" is missing in bulk indexed records. Can anyone help me what I did wrong?

My BulkRequest builder looks like this

```auto
 final BulkResponse response = client.bulk(builder -> {
            for (Product product : products) {
                builder.index(index)
                       .operations(ob -> {
                           if (product.getId() != null) {
                               ob.index(ib -> ib.document(product).id(product.getId()));
                           } else {
                               ob.index(ib -> ib.document(product));
                           }
                           return ob;
                       });
            }
            return builder;
        });

```

I'm not able to figure out what went wrong.

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [April 10, 2024, 8:51am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-indexing-the-documents-using-java-api-client/356995/2 "2024-04-10T08:51:02Z")

</div>

It seems that your ElasticsearchRepository is converting camelCase names ("userName") to snake\_case ("user\_name") when inserting documents in Elasticsearch.

You should look a the configuration of your ElasticsearchRepository.

---

<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 8, 2024, 8:51am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-indexing-the-documents-using-java-api-client/356995/3 "2024-05-08T08:51:49Z")

</div>

Closed on May 8, 2024, 8:51am UTC

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