# Different behavior on index shards when apply index mapping

**URL:** <https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697>\
**Category:** Elasticsearch\
**Created:** [August 27, 2021, 5:52pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697 "2021-08-27T17:52:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fdsm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fdsm/32/83252_2.png) [@Fdsm](https://discuss.elastic.co/u/Fdsm)\
**Post date:** [August 27, 2021, 5:52pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/1 "2021-08-27T17:52:47Z")

</div>

Hello,

We watch a curious behavior after apply a index mapping on indices:

Before mapping, it was not notice any docs\_deleted on indeces and size of the primary and replica shards were basicaly same:

Before custom mapping apply (None docs.deleted and pri.store basically 50% of total store.size)

```auto
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open index3-2021.08.25 1 1 1473137 0 82.2gb 41.1gb
green open index2-2021.08.24 1 1 1659334 0 90.5gb 45.3gb
green open index1-2021.08.23 1 1 1812586 0 83.4gb 41.6gb

```

After custom mapping apply (some docs were deleted and pri.store about 77% of store.size

```auto
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open index4-2021.08.26 1 1 1171672 1325 6.1gb 4.7gb

[
{
"index" : "index4-2021.08.26",
"shard" : "0",
"prirep" : "r",
"state" : "STARTED",
"docs" : "1124449",
"store" : "1.4gb",
"ip" : "ipsnode1",
"node" : "host1"
},
{
"index" : "index4-2021.08.26",
"shard" : "0",
"prirep" : "p",
"state" : "STARTED",
"docs" : "1171672",
"store" : "4.7gb",
"ip" : "ipsnode2",
"node" : "host2"
}
]

```

Data were ingested without any change other than mapping. Any clues if this disbalancing shard storage might be an issue and why these documents were deleted?

I know that primary and replica shads are not necessary stored the same way. but the difference is huge

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 30, 2021, 1:23am UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/2 "2021-08-30T01:23:21Z")

</div>

Welcome to our community! 😃

We'd need to see the mappings to make comments on what might be happening, please share them.

---

<div class="post-metadata">

**Author:** ![Fdsm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fdsm/32/83252_2.png) [@Fdsm](https://discuss.elastic.co/u/Fdsm)\
**Post date:** [August 30, 2021, 1:27pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/3 "2021-08-30T13:27:33Z")

</div>

Follows the mapping:

```auto
PUT _index_template/index
{
  "index_patterns": ["index*"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1,
      "index.lifecycle.name": "index",
      "index.lifecycle.rollover_alias": "index"
    },
    "mappings" : {
      "dynamic_templates": [
      {
      	"string": {
      	  "match_mapping_type": "string",
      	  "mapping": {
      	  	"type": "keyword"
      	  }
      	}
      }
      ],
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "@version" : {
          "type" : "keyword"
        },
        "application" : {
          "properties" : {
            "name" : {
              "type" : "keyword"
            },
            "version" : {
              "type" : "keyword"
            }
          }
        },
        "client" : {
          "type" : "ip"
        },
        "level" : {
          "type" : "keyword"
        },
        "logger_name" : {
          "type" : "text",
          "norms": false,
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "message" : {
          "type" : "text",
          "norms": false
        },
        "method" : {
          "type" : "keyword"
        },
        "mongoDb" : {
          "properties" : {
            "collection" : {
              "type" : "keyword"
            },
            "dataBaseName" : {
              "type" : "keyword"
            },
            "nameMethod" : {
              "type" : "keyword"
            },
            "totalTimeMillis" : {
              "type" : "float"
            }
          }
        },
        "port" : {
          "type" : "keyword"
        },
        "processingTimeMillis" : {
          "type" : "float"
        },
        "request" : {
          "properties" : {
            "body" : {
              "type" : "text",
              "norms": false,
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "headers" : {
              "properties" : {
                "Content-Type" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "catalogcode" : {
                  "type" : "keyword"
                },
                "channel" : {
                  "type" : "keyword"
                },
                "city" : {
                  "type" : "keyword"
                },
                "customerid" : {
                  "type" : "keyword"
                },
                "fidelization" : {
                  "type" : "keyword"
                },
                "forwarded" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "headercliente" : {
                  "type" : "keyword"
                },
                "host" : {
                  "type" : "keyword"
                },
                "name" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "ordernumber" : {
                  "type" : "keyword"
                },
                "paymentmean" : {
                  "type" : "keyword"
                },
                "pdv" : {
                  "type" : "keyword"
                },
                "postman-token" : {
                  "type" : "keyword"
                },
                "source" : {
                  "type" : "keyword"
                },
                "transactionid" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "uf" : {
                  "type" : "keyword"
                },
                "user-agent" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "x-forwarded-for" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "x-forwarded-host" : {
                  "type" : "text",
                  "norms": false,
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "x-forwarded-port" : {
                  "type" : "keyword"
                },
                "x-forwarded-proto" : {
                  "type" : "keyword"
                }
              }
            },
            "method" : {
              "type" : "keyword"
            },
            "url" : {
              "type" : "keyword"
            }
          }
        },
        "requestId" : {
          "type" : "keyword"
        },
        "response" : {
          "properties" : {
            "body" : {
              "type" : "text",
              "norms": false
            }
          }
        },
        "stackTrace" : {
          "type" : "text",
          "norms": false
        },
        "statusCode" : {
          "type" : "keyword"
        },
        "tags" : {
          "type" : "keyword"
        },
        "traceId" : {
          "type" : "keyword"
        }
      }
    },
    "aliases": {
      "index": {}
    }
   },
  "version": 1
}

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 30, 2021, 10:11pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/4 "2021-08-30T22:11:03Z")

</div>

And what was the original mapping?

---

<div class="post-metadata">

**Author:** ![Fdsm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fdsm/32/83252_2.png) [@Fdsm](https://discuss.elastic.co/u/Fdsm)\
**Post date:** [August 30, 2021, 11:13pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/5 "2021-08-30T23:13:54Z")

</div>

Hi, Mark.

Follows original mapping (several fields have been removed because of character limitation, but the original mapping is basically multifields text/keyword and long for numeric fields)

```auto
{
  "index-2021.08.25" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "@version" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "LEVEL" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "LOGSTASH" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "X-B3-ParentSpanId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "X-B3-SpanId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "X-B3-TraceId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "X-Span-Export" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "application" : {
          "properties" : {
            "name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "version" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "className" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "client" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "clientHost" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "feign" : {
          "properties" : {
            "configKey" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "level" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "processingTimeMillis" : {
              "type" : "long"
            },
            "request" : {
              "properties" : {
                "body" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "charset" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "headers" : {
                  "properties" : {
                    "Accept" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "Authorization" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "Cliente" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "Content-Length" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "Content-Type" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "X-B3-ParentSpanId" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "X-B3-Sampled" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "X-B3-SpanId" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "X-B3-TraceId" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "appId" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "cpf" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "proxyAuth" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "proxyauth" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "scope" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "transactionId" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    }
                  }
                },
                "method" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "url" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            },
            "response" : {
              "properties" : {
                "body" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "headers" : {
                  "properties" : {
                    "cache-control" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "connection" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    },
                    "content-length" : {
                      "type" : "text",
                      "fields" : {
                        "keyword" : {
                          "type" : "keyword",
                          "ignore_above" : 256
                        }
                      }
                    }
      }
    }
  }
}

```

---

<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:** [September 27, 2021, 11:14pm UTC](https://discuss.elastic.co/t/different-behavior-on-index-shards-when-apply-index-mapping/282697/6 "2021-09-27T23:14:15Z")

</div>

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