我有一个关于Elasticsearch的问题。
如果我有两个索引IndexA和IndexB。
我将ID为“ 1”的文档docA放入了IndexA,并将ID为“ 1”的文档docB放入了IndexB。这些文档具有相同的文档类型,但正文不同(结构相同但值不同)。
如果我创建一个别名“ alias1”同时指向IndexA和IndexB并获取以下内容的获取请求,将会发生什么?
response = es_client.get(index =“ alias1”,doc_type =“ doc_type”,id =“ 1”)
答案 0 :(得分:0)
这很容易测试,但是总之,您不能使用和指向多个索引的别名为文档颁发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
}