升级到Elasticsearch 5.2

时间:2017-03-27 21:07:16

标签: elasticsearch

我有以下传统映射代码在ES 1.7中有效但在5.2中失败。失败的事情是不支持multi_field以及路径。该文档提到这些字段已被删除但未提供补救措施,建议使用copy_to。罐头的人可以提供更多细节。

{
"sample": {
    "_parent": {
        "type": "security"
    },
    "properties": {
        "securityDocumentId": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": false
        },
        "id": {
            "type": "multi_field",
            "path": "full",
            "fields": {
                "indexer_sample_id": {
                    "type": "string"
                },
                "id": {
                    "type": "string",
                    "include_in_all": false
                }
            }
        },
        "sampleid": {
            "type": "multi_field",
            "path": "just_name",
            "fields": {
                "sampleid": {
                    "type": "string",
                    "analyzer": "my_analyzer"
                },
                "sample.sampleid": {
                    "type": "string",
                    "analyzer": "my_analyzer"
                },
                "sample.sampleid.sort": {
                    "type": "string",
                    "analyzer": "case_insensitive_sort_analyzer"
                },
                "sample.sampleid.name.autocomplete": {
                    "type": "string",
                    "analyzer": "autocomplete"
                }
            }
        },

1 个答案:

答案 0 :(得分:1)

path选项的默认值为full,因此您可以将其保留,因为它在2.0中已弃用。 pathjust_name不再存在,您必须按其完整路径名引用所有字段。可以非常简单地重写多字段:

{
"sample": {
    "_parent": {
        "type": "security"
    },
    "properties": {
        "securityDocumentId": {
            "type": "keyword",
            "include_in_all": false
        },
        "id": {
            "type": "text",
            "fields": {
                "indexer_sample_id": {
                    "type": "text"
                },
                "id": {
                    "type": "text",
                    "include_in_all": false
                }
            }
        },
        "sampleid": {
            "type": "text",
            "fields": {
                "sampleid": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "sample.sampleid": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "sample.sampleid.sort": {
                    "type": "text",
                    "analyzer": "case_insensitive_sort_analyzer"
                },
                "sample.sampleid.name.autocomplete": {
                    "type": "text",
                    "analyzer": "autocomplete"
                }
            }
        },

请注意,我不确定id子字段的用途和附加值