Disable dynamic mapping creation for only specific indexes on elasticsearch?

后端 未结 4 1867
死守一世寂寞
死守一世寂寞 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:46

    You must know about that the below part just mean that ES could'nt create a type dynamically.

    "mapper" : {
            "dynamic" : false
        }
    

    You should configure ES like this:

    PUT http://localhost:9200/test_idx/_mapping/test_type
    {
      "dynamic":"strict"
    }
    

    Then you cant't index other field that without mapping any more ,and get an error as follow:

    mapping set to strict, dynamic introduction of [hatae] within [data] is not allowed
    

    If you wanna store the data,but make the field can't be index,you could take the setting like this:

    PUT http://localhost:9200/test_idx/_mapping/test_type
    {
      "dynamic":false
    }
    

    Hope these can help the people with the same issue :).

提交回复
热议问题