Is 是弹性存储每个别名的索引模板的任何方式。 我的意思是创建具有多个别名(别名 1 、别名 2 ..)的索引,并为每个别名附加不同的模板。然后对特定别名执行索引/搜索文档。
我这样做的原因是文档有多种不同的数据结构(最多 50 种)。
到目前为止我所做的是:
1. PUT /dynamic_index
2. POST /_aliases
{ "actions" : [
{ "add" : { "index" : "dynamic_index", "alias" : "alias_type1" } },
{ "add" : { "index" : "dynamic_index", "alias" : "alias_type2" } },
{ "add" : { "index" : "dynamic_index", "alias" : "alias_type3" } }
]}
3.
PUT_template/template1 {
"index_patterns": [
"dynamic_index"
],
"mappings": {
"dynamic_templates": [
{
"strings_as_keywords": {
"match_mapping_type": "string",
"mapping": {
"type": "text",
"analyzer": "standard",
"copy_to": "_all",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
}
}
}
}
],
"properties": {
"source": {
"type": "keyword"
}
}
},
"aliases": {
"alias_type1": {
}
}
}
4. same way to alias_type2 , alias_type3 but different fields ...
索引/搜索:尝试按别名创建和搜索文档,例如:
POST alias_type1/_doc
{
"source": "foo"
, .....
}
POST alias_type2/_doc
{
"source": "foo123"
, .....
}
GET alias_type1/_search
{
"query": {
"match_all": {}
}
}
GET alias_type2/_search
{
"query": {
"match_all": {}
}
}
我实际上看到的是,即使我按别名索引文档, 搜索时,我没有看到每个别名的结果,alias_type1,2 甚至索引上的所有结果都相同。
有什么办法可以在每个别名(别名)的搜索/索引文档方面实现每个别名的分离逻辑?
有什么想法吗?
答案 0 :(得分:0)
您不能为指向同一索引的别名进行单独的映射!别名就像指向索引的虚拟链接,因此如果您的别名指向相同的索引,您将获得相同的结果。 如果你想根据你的数据结构有不同的映射,你需要创建多个索引。
更新 您也可以使用基于字段的自定义路由以获取更多信息,您可以查看 Elastic 官方文档 here。