我创建了一个包含单个分片和 1 个副本的索引。我正在运行 ElasticSearch 版本 1.0.1 并且集群有 3 个节点。
我注意到,有时具有相同分数的文档的结果排序是
根据是否针对主数据库和副本数据库运行相同的查询而有所不同。
该查询是匹配查询。
例如,当针对主要运行时,结果为:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 9.058382,
"hits": [
{
"_index": "testdocs",
"_type": "testdocs",
"_id": "132898",
"_score": 9.058382
},
{
"_index": "testdocs",
"_type": "testdocs",
"_id": "132888",
"_score": 9.058382
}
]
}
}
当针对副本运行时:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 9.058382,
"hits": [
{
"_index": "testdocs",
"_type": "testdocs",
"_id": "132888",
"_score": 9.058382
},
{
"_index": "testdocs",
"_type": "testdocs",
"_id": "132898",
"_score": 9.058382
}
]
}
}
不是上面结果顺序中“_id”的变化。
我无法用部分文档来复制它。我相信当副本中的段数与主段数不同时,似乎会发生这种情况。
在上述情况下,副本的数量为 21,而主副本的数量为 28。然而,两者具有相同数量的文档,因此数据是一致的。
我的问题是,这是预期的行为吗,即对于具有相同分数的文档,ES 不提供默认排序示例:按 _id 排序?
是通过 _score 和 _id 显式对结果进行排序的唯一方法,还是我缺少其他一些设置。