0
votes

I have created an index template, where I am defining an "ignore_above" mapping parameter for a "keyword" field type.

Now I want to update the mappings and want to add a new parameter "eager_global_ordinals" for the same "keyword" field using the PUT mappings API,

I can see the API returning 200OK.

So to verify the mapping when I call GET index-name, I can see the new mappings "eager_global_ordinals", but not able to see "ignore_above"?

I checked, and found out that "ignore_above" property is getting overrided with default value?

Meaning PUT mappings API overriding the mappings parameter to default value, if i dont pass any.

is there any way to avoid this behavior?

Commands I have tried in sequence:

PUT /_index_template/example_template
{
   "index_patterns": [
        "example*"
    ],
    "priority": 1,
    "template": {
        "aliases": {
            "example":{}
        },
    "mappings": {
      "_source":
      {"enabled": false},
      "properties": {
       "SomeID":
        { "type": "keyword", "index" : true,"store":true,"ignore_above":5}
      }
    }
  }
}

PUT example10022021
GET example10022021

In this GET API response you can see "ignore_above" parameter in mappings

PUT /example/_mappings
{
    "properties": {
      "SomeID": {
        "type": "keyword",
        "store":true,
        "eager_global_ordinals":true
      }
    }
}

Now again

GET example10022021

Now you can see in the response that "ignore_above" parameter is NOT present

1
Can you share the commands you've run so we can reproduce the issue?Val
@Val Thanks for reaching out! I have updated the question with API I have tried, can you please help?Nishikant Tayade

1 Answers

0
votes

That's correct, for the same reason you need to re-specify store: true otherwise the update doesn't work (because it would take the default value which is false), you also need to re-specify ignore_above: 5:

So you can do it like this:

PUT /example/_mappings
{
    "properties": {
      "SomeID": {
        "type": "keyword",
        "store":true,
        "ignore_above": 5,
        "eager_global_ordinals":true
      }
    }
}