Disable dynamic mapping creation for only specific indexes on elasticsearch?

后端 未结 4 1868
死守一世寂寞
死守一世寂寞 2020-12-09 04:08

I\'m trying to disable dynamic mapping creation for only specific indexes, not for all. For some reason I can\'t put default mapping with \'dynamic\' : \'false\'. S

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 04:48

    The answer is in the doc (7x.): https://www.elastic.co/guide/en/elasticsearch/reference/7.x/dynamic.html

    The dynamic setting controls whether new fields can be added dynamically or not. It accepts three settings:

    true

    Newly detected fields are added to the mapping. (default)

    false

    Newly detected fields are ignored. These fields will not be indexed so will not be searchable but will still appear in the _source field of returned hits. These fields will not be added to the mapping, new fields must be added explicitly.

    strict

    If new fields are detected, an exception is thrown and the document is rejected. New fields must be explicitly added to the mapping.

    PUT my_index
    {
      "mappings": {
        "dynamic": "strict", 
        "properties": {
          "user": { 
            "properties": {
              "name": {
                "type": "text"
              },
              "social_networks": { 
                "dynamic": true,
                "properties": {}
              }
            }
          }
        }
      }
    }
    

提交回复
热议问题