gpt4 book ai didi

elasticsearch - _mget 和 _search 在 ElasticSearch 上的区别

转载 作者:行者123 更新时间:2023-12-03 02:00:30 27 4
gpt4 key购买 nike

我已经索引了 2 个文档:

如您所见,在将这些索引编入索引后,我可以在搜索结果中看到它们:

[root@centos7 ~]# curl 'http://ESNode01:9201/living/fuas/_search?pretty'
{
"took" : 20,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2, <<<<<<<<<<<<<<<<
"max_score" : 1.0,
"hits" : [ {
"_index" : "living",
"_type" : "fuas",
"_id" : "idFuaMerge1", <<<<<<<<<<<<<<<
"_score" : 1.0,
"_source":{"timestamp":"2015-10-14T16:13:49.004Z","matter":"null","comment":"null","status":"open","backlogStatus":"unknown","metainfos":[],"resources":[{"resourceId":"idResourceMerge1","noteId":"null"},{"resourceId":"idResourceMerge2","noteId":null}]}
}, {
"_index" : "living",
"_type" : "fuas",
"_id" : "idFuaMerge2", <<<<<<<<<<<<<<<<<<
"_score" : 1.0,
"_source":{"timestamp":"2015-10-14T16:13:49.004Z","matter":"null","comment":"null","status":"open","backlogStatus":"unknown","metainfos":[],"resources":[{"resourceId":"idResourceMerge3","noteId":null}]}
} ]
}
}

之后,我执行一个 multiget 请求来设置文档 ID:
[root@centos7 ~]# curl 'http://ESNode01:9201/living/fuas/_mget?pretty' -d '
{
"ids": ["idFuaMerge1", "idFuaMerge2"]
}
'
{
"docs" : [ {
"_index" : "living",
"_type" : "fuas",
"_id" : "idFuaMerge1",
"found" : false <<<<<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!
}, {
"_index" : "living",
"_type" : "fuas",
"_id" : "idFuaMerge2",
"_version" : 4,
"found" : true, <<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!
"_source":{"timestamp":"2015-10-14T16:13:49.004Z","matter":"null","comment":"null","status":"open","backlogStatus":"unknown","metainfos":[],"resources":[{"resourceId":"idResourceMerge3","noteId":null}]}
} ]
}

究竟如何,在一个 multiget 请求中,第一个文档是 不是 发现而另一个呢?

最佳答案

只有当您使用路由键来索引您的文档时,才会发生这种情况。甚至父子关系也可以暗示相同。

当给定一个文档进行索引时,该文档使用路由机制映射到一个唯一的分片。在这种机制中,docID 被转换为散列,并对该散列进行模运算以确定文档应该转到哪个分片。
所以简而言之

对于 documentA,默认分片可能是 1。默认分片是根据路由键计算的。

但是因为你自己应用了路由键,所以这个文档被映射到了不同的分片,告诉 0。

现在,当您尝试在没有路由键的情况下获取文档时,它希望文档位于 shard 1 而不是 shard 0 中,因此您的 multi get 失败,因为它直接在 shard 1 中查找以获取文档。

搜索有效,因为搜索操作发生在所有分片/

关于elasticsearch - _mget 和 _search 在 ElasticSearch 上的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33130753/

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