elasticsearch - 在 elasticsearch 上排序未按预期工作
问题描述
我有如下的 ES 查询:
{"query":{"bool":{"must":[{"bool":{"should":[{"bool":{"must":[{"bool":{"should":[{"match":{"*login*":{"query":"jyo","operator":"and"}}}]}}],"boost":1.34}}]}}]}},"sort":[{"_uid":"desc"}]}
The output is :
{
"took": 77,
"timed_out": false,
"_shards": {
"total": 33,
"successful": 33,
"failed": 0
},
"hits": {
"total": 4,
"max_score": null,
"hits": [
{
"_index": "hobbes1.qa_en_19_2",
"_type": "esuser",
"_id": "6",
"_score": null,
"sort": [
"esuser#6"
]
},
{
"_index": "hobbes1.qa_en_19_2",
"_type": "esuser",
"_id": "5",
"_score": null,
"sort": [
"esuser#5"
]
},
{
"_index": "hobbes1.qa_en_19_2",
"_type": "esuser",
"_id": "4",
"_score": null,
"sort": [
"esuser#4"
]
},
{
"_index": "hobbes1.qa_en_19_2",
"_type": "esuser",
"_id": "10003",
"_score": null,
"sort": [
"esuser#10003"
]
}
]
}
}
如果按_id排序,那么10003不应该排在最前面吗?我正在使用弹性搜索 1.7 版。请帮忙。
解决方案
因为_id
is not a number
but a string
,所以“10003”在字符串比较时小于“4”、“5”或“6”。
推荐阅读
- python - python 3 summing numbers from input
- create-table - Greenplum creates a partition table is very slow
- github - 无法将代码推送到 gitlab 存储库
- javascript - React/Redux 中的通用化简器/动作
- ms-access-2016 - 我想有条件地为 ms-access 中的自动编号或编号添加前缀
- sql - 根据条件为其他列选择一个列值
- java - 将新项目添加到现有项目 android 应用程序(如何移动到下一个活动)
- python - opencv imutils 调整视频流的大小
- javascript - JS转换成的JSON不能被PHP解码
- excel - 无法在特定网站上执行自动搜索