# Explicit mappingに存在しないプロパティは動的に追加されますか？

**URL:** <https://discuss.elastic.co/t/explicit-mapping/116424>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [January 22, 2018, 2:51am UTC](https://discuss.elastic.co/t/explicit-mapping/116424 "2018-01-22T02:51:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smogami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smogami/32/26787_2.png) [@smogami](https://discuss.elastic.co/u/smogami)\
**Post date:** [January 22, 2018, 2:51am UTC](https://discuss.elastic.co/t/explicit-mapping/116424/1 "2018-01-22T02:51:17Z")

</div>

使用中のElasticsearchバージョン: v5.5

[Index template](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html)で作成した expliciti mapping があり、多数のドキュメントを格納しています。

アプリケーション側での必要性から、既存ドキュメントに新しいプロパティを追加してインデックスしたところ、そのプロパティがmappingに追加されないようでした。

そこで質問なのですが、

- Explicit mappingに存在しないプロパティは動的に追加されていきますか
- されない場合は、明示的にPut Mapping APIでmappingを更新してからインデックスすればよいでしょうか

なお、上記ページで "Templates are only applied at index creation time. Changing a template will have no impact on existing indices. "（Index templateはindex作成時にのみ適用される）と上述のドキュメントにありましたので、Index templateは更新していません。

参考のため、以下のようなIndex templateがあり、

```json
{
  "template": "*.foo",
  "settings": {

  },
  "mappings": {
    "bar": {
      "properties": {
        "name": {
          "type": "keyword"
        }
      }
    }
  }
}

```

この `bar` に、新しいプロパティ `hoge` を持つドキュメントを追加しようとしております。

---

<div class="post-metadata">

**Author:** ![smogami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smogami/32/26787_2.png) [@smogami](https://discuss.elastic.co/u/smogami)\
**Post date:** [January 22, 2018, 4:58am UTC](https://discuss.elastic.co/t/explicit-mapping/116424/2 "2018-01-22T04:58:38Z")

</div>

自己解決いたしました。

質問の「Explicit mappingに存在しないプロパティは動的に追加されますか？」の答えは、  
「追加される」で合っているようです。

当方で追加されていないようにみえた原因は、当方のアプリケーション側の不具合でした。  
新しいプロパティがない古い形式のJSONがElasticsearchにインデックスされておりました…。

---

<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:** [February 19, 2018, 4:59am UTC](https://discuss.elastic.co/t/explicit-mapping/116424/3 "2018-02-19T04:59:02Z")

</div>

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