ElasticSearch 6,带有动态索引映射的copy_to [英] ElasticSearch 6, copy_to with dynamic index mappings
问题描述
也许我遗漏了一些简单的东西,但仍然找不到以下内容:
Maybe I'm missing something simple, but still could not figure out the following thing:
从ES 6.x开始, _all
字段已弃用,建议使用 copy_to
指令( https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html )。
As of ES 6.x the _all
field is deprecated, and instead it's suggested to use the copy_to
instruction (https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html).
但是,我的印象是,您需要明确指定要复制到自定义 _all $ c的字段$ c>字段。但是,如果我使用动态映射,则我不事先知道字段,因此不能使用
copy_to
?
However, I got an impression that you need to explicitly specify the fields which you want to copy to the custom _all
field. But if I use dynamic mappings, I don't know the fields in advance, and therefore cannot use copy_to
?
可以通过什么方式告诉ES将所有遇到的字段复制到自定义 _all
字段中,以便我可以在所有字段中进行搜索?
Any way I can tell ES to copy all encountered fields to the custom _all
field so that I can search across all fields?
预先感谢!
推荐答案
您可以使用动态模板。基本上创建一个索引,添加自定义 catch_all
字段,然后为所有字符串字段指定该特定属性。 (以前没有做过,但是我相信这是现在的唯一方法。由于当您放置动态模板时, catch_all
字段已经存在,因此不会匹配 catch_all
-表示 catch_all
不会复制到自身,而是自己检查以确保。)
You could use Dynamic Templates. Basically create an index, add the custom catch_all
field and then specify that particular property for all the fields that are strings. (Haven't done this before, but I believe this is the only way now. Since the field catch_all
will be already present when you put the dynamic template, it will not match the catch_all
- meaning that the catch_all
will not copy to itself, but check it out yourself to make sure).
PUT my_index
{
"mappings": {
"_doc": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "text",
"copy_to": "catch_all"
}
}
}
]
}
}
}
这篇关于ElasticSearch 6,带有动态索引映射的copy_to的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!