Disable dynamic mapping creation for only specific indexes on elasticsearch?

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

    You cannot disable dynamic mapping in ES 7 anymore, what you can do if you have completely unstructured data is to disable completely the mapping for the index like this:

    curl -X PUT "localhost:9200/my_index?pretty" -H 'Content-Type: application/json' -d'
    {
      "mappings": {
        "enabled": false 
      }
    }
    '
    

    if you are using python you can do this:

    from elasticsearch import Elasticsearch
    
    # Connect to the elastic cluster
    es=Elasticsearch([{'host':'localhost','port':9200}])
    
    request_body = {
            "mappings": {
                     "enabled": False
        }
    }
    es.indices.create(index = 'my_index', body = request_body)
    

提交回复
热议问题