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

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

{
  "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

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

It should...

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

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

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.

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

{
  "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"
          }
        }
      }
    ]
  }
}

command I used to define
PUT ESURL/machine_report_lowercase
above payload in payload

And what do you get when running:

GET /machine_report_lowercase/_mapping

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

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