# Elastic creating new Index on Bulk Api even though mapping is already provided

**URL:** <https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [April 4, 2023, 8:30am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294 "2023-04-04T08:30:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![suresh\_chaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_chaudhari/32/106602_2.png) [@suresh\_chaudhari](https://discuss.elastic.co/u/suresh_chaudhari)\
**Post date:** [April 4, 2023, 8:30am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/1 "2023-04-04T08:30:13Z")

</div>

Hi Community Members

Using Elastic 8 with JAVA client.I first created template of mapping like below  
Index Name=A is created two in elastic 8 server instead of overwritingalready present mapping file

```auto
{
  "settings": {
    "index": {
      "analysis": {
        "normalizer": {
          "my_normalizer": {
            "type": "custom",
            "char_filter": [],
            "filter": [
              "lowercase"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "keyword",
            "ignore_above": 256,
            "normalizer": "my_normalizer"
          }
        }
      }
    ]
  }
}

```

=======  
Now I am using java Client to bulk index docs

```auto
co.elastic.clients.elasticsearch.core.BulkRequest.Builder bulkBuilder=new Builder();

                    for (MyObj o : obj) {
                        bulkBuilder.operations(op->op.index(idx->idx.index(INDEX_NAME).document(o)));

                    }

```

======  
RESULT it does not overwrite already created Indexname it creates new mapping after bulk api starts filling documents

---

<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:** [April 4, 2023, 8:53am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/2 "2023-04-04T08:53:18Z")

</div>

It should...

Here's how I'm doing it on another project:

> <https://github.com/dadoonet/legacy-search/blob/ae9bd89fc65b8812c2e4f2a514fbb5937e8bdf75/src/main/java/fr/pilato/demo/legacysearch/dao/ElasticsearchDao.java#L115-L121>

**Note** : to be more efficient (payload wise), I'd rewrite your code as is:

```auto
co.elastic.clients.elasticsearch.core.BulkRequest.Builder bulkBuilder=new Builder();
bulkBuilder.index(INDEX_NAME);
for (MyObj o : obj) {
  bulkBuilder.operations(op->op.index(idx->idx.document(o)));
}

```

As it does not work for you, could you share the template mapping you defined (and the command you used to define it)?  
Also, what is the real index name. I suppose it's not `A`.

---

<div class="post-metadata">

**Author:** ![suresh\_chaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_chaudhari/32/106602_2.png) [@suresh\_chaudhari](https://discuss.elastic.co/u/suresh_chaudhari)\
**Post date:** [April 4, 2023, 9:12am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/3 "2023-04-04T09:12:43Z")

</div>

Hi Sir,  
I am really thankful how you quickly respond to the queries  
My index name is machine\_report\_lowercase  
first I create dynamic template using

```auto
{
  "settings": {
    "index": {
      "analysis": {
        "normalizer": {
          "my_normalizer": {
            "type": "custom",
            "char_filter": [],
            "filter": [
              "lowercase"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "keyword",
            "ignore_above": 256,
            "normalizer": "my_normalizer"
          }
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![suresh\_chaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_chaudhari/32/106602_2.png) [@suresh\_chaudhari](https://discuss.elastic.co/u/suresh_chaudhari)\
**Post date:** [April 4, 2023, 9:14am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/4 "2023-04-04T09:14:34Z")

</div>

command I used to define  
PUT ESURL/machine\_report\_lowercase  
above payload in payload

---

<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:** [April 4, 2023, 9:25am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/5 "2023-04-04T09:25:35Z")

</div>

And what do you get when running:

```auto
GET /machine_report_lowercase/_mapping

```

---

<div class="post-metadata">

**Author:** ![suresh\_chaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suresh_chaudhari/32/106602_2.png) [@suresh\_chaudhari](https://discuss.elastic.co/u/suresh_chaudhari)\
**Post date:** [April 4, 2023, 10:39am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/6 "2023-04-04T10:39:27Z")

</div>

I get only one index mapping .this issue got resolved after i created another index with diffrent name.May be it was chrome elastichead plugin it went crazy showing two index with same name when i searched index in elastic head plugin.  
Sorry for bothering 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:** [May 2, 2023, 10:40am UTC](https://discuss.elastic.co/t/elastic-creating-new-index-on-bulk-api-even-though-mapping-is-already-provided/329294/7 "2023-05-02T10:40:17Z")

</div>

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