Elasticsearch多字段索引

问题描述 投票:0回答:1

假设我有一个名为'Title'的字段,我想使用不同的分析器(标准和英语)对其进行索引。使用多字段映射或创建两个单独的字段之间有区别吗?

使用多字段映射:https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-fields.html

"mappings": {
    "my_type": {
        "properties": {
            "title": { 
                "type":     "string",
                "analyzer": "english",
                "fields": {
                    "std":   { 
                        "type":     "string",
                        "analyzer": "standard"
                    }
                }
            }
        }
    }
}

有两个单独的字段:

{
    "properties": {
        "title_standard": {
            "type": "text",
            "analyzer": "standard"
        },
        "title_english": {
            "type": "text",
            "analyzer": "english"
        }
    }
}
elasticsearch elasticsearch-5
1个回答
0
投票

主要区别在于如何将字段发送到elasticsearch。

使用multi-field,您只需要发送一个字段,elasticsearch将使用映射中指定的分析器或类型创建一个新字段。

使用两个字段,您需要先复制原始字段并发送它们,它们将被视为elasticsearch的两个不同字段。

© www.soinside.com 2019 - 2024. All rights reserved.