Change default mapping of string to “not analyzed” in Elasticsearch

后端 未结 4 1140
星月不相逢
星月不相逢 2020-11-29 23:29

In my system, the insertion of data is always done through csv files via logstash. I never pre-define the mapping. But whenever I input a string it is always taken to be

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 23:55

    Just create a template. run

    curl -XPUT localhost:9200/_template/template_1 -d '{
        "template": "*",
        "settings": {
            "index.refresh_interval": "5s"
        },
        "mappings": {
            "_default_": {
                "_all": {
                    "enabled": true
                },
                "dynamic_templates": [
                    {
                        "string_fields": {
                            "match": "*",
                            "match_mapping_type": "string",
                            "mapping": {
                                "index": "not_analyzed",
                                "omit_norms": true,
                                "type": "string"
                            }
                        }
                    }
                ],
                "properties": {
                    "@version": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "geoip": {
                        "type": "object",
                        "dynamic": true,
                        "path": "full",
                        "properties": {
                            "location": {
                                "type": "geo_point"
                            }
                        }
                    }
                }
            }
        }
    }'
    

提交回复
热议问题