gpt4 book ai didi

elasticsearch - Elasticsearch别名和索引(相同的ID?)

转载 作者:行者123 更新时间:2023-12-02 23:58:06 24 4
gpt4 key购买 nike

我有一个关于Elasticsearch的问题。

如果我有两个索引IndexA和IndexB。

我将ID为“1”的文档docA放入了IndexA,并将ID为“1”的文档docB放入了IndexB。这些文档的文档类型相同,但正文不同(结构相同但值不同)。

如果我创建一个别名“alias1”同时指向IndexA和IndexB并获取以下内容的请求,将会发生什么?

响应= 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
}

关于elasticsearch - Elasticsearch别名和索引(相同的ID?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51565858/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com