ElasticSearch“索引-模板”Map定义(copy_to?)

xjreopfe  于 2023-06-21  发布在  ElasticSearch
关注(0)|答案(1)|浏览(103)

我正在为文档定义一个索引模板,它具有未知数量的字段(字段本身也是未知的)。
我想为索引设置Map定义,我可以在整个文档中执行(在我的网站UI中)文本搜索(不区分大小写),在每个单独的字段中进行文本搜索(不区分大小写),并按每个字段进行排序(所有数字或字符串)。
这样做对吗?通过使用dynamic_template并向他提供:

[
    {
        "strings_as_keyword": {
            "match_mapping_type": "string",
            "mapping": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            }
        }
    },
    {
        "numbers_as_double": {
            "match_mapping_type": "long",
            "mapping": {
                "type": "double"
            }
        }
    }
]

我是否应该使用copy_to进行完整文档搜索?

yvfmudvl

yvfmudvl1#

Tldr;

是的,如果你计划在很多领域进行大量搜索,你最好把所有这些领域都集中在一个领域。

解决方案:

PUT 76433872
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings_as_text": {
          "match_mapping_type": "string",
          "path_unmatch": "all_text",
          "mapping": {
            "type": "text",
            "copy_to": "all_text"
          }
        }
      }
    ]
  }
}

相关问题