elasticsearch - Elasticsearch 别名和索引(相同的 id?)
问题描述
我有一个关于 Elasticsearch 的问题。
如果我有 2 个索引 IndexA 和 IndexB。
我将id为“1”的文档docA放在IndexA中,并将id为“1”的文档docB放在IndexB中。文档具有相同的文档类型但正文不同(结构相同但值不同)。
如果我创建一个指向 IndexA 和 IndexB 的别名“alias1”并执行以下获取请求,会发生什么?
响应 = es_client.get(index="alias1", doc_type="doc_type", id="1")
解决方案
它很容易测试,但简而言之,您不能为使用指向多个索引的文档和别名发出 GET !
PUT index1/doc/1
{ "test": 1 }
PUT index2/doc/1
{ "test": 2 }
POST _aliases
{
"actions" : [
{ "add" : { "index" : "index1", "alias" : "alias1" } },
{ "add" : { "index" : "index2", "alias" : "alias1" } }
]
}
GET alias1/doc/1
=>
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Alias [alias1] has more than one indices associated with it [[index2, index1]], can't execute a single index op"
}
],
"type": "illegal_argument_exception",
"reason": "Alias [alias1] has more than one indices associated with it [[index2, index1]], can't execute a single index op"
},
"status": 400
}
推荐阅读
- vector - 在 Rust 中,当向量 v 的大小为 1 时,为什么 &v[1..] 不恐慌?
- javascript - API Fetch 问题:未处理的承诺拒绝:SyntaxError:JSON 解析错误:意外的标识符“服务器”
- azure - 使用 REST API 在 Go 中对 Azure 进行身份验证
- google-bigquery - 无论存储引擎类型如何,它们是否支持单个 DDL 和 DML SQL 语句的事务?
- visual-studio-code - 在当前 VSCode 目录中打开 WSL 终端而不使用 VSCode 服务器
- android - 为什么firebase身份验证返回null?
- python - 使用 Spacy nlp 合并两个 CSV 文件
- c - 如果没有提供其他标志,是否会在 EPOLLERR/EPOLLHUP 上唤醒 epoll?
- django - Django Celery Redis 身份验证
- kubernetes - 将指标移入 Kubernetes 集群