簡體   English   中英

按彈性搜索排序不按預期工作

[英]sort by on elasticsearch not working as expected

我有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不應該在頂部嗎? 我使用的是elasticsearch 1.7版。 請幫忙。

因為_id不是number而是string ,所以“10003”在字符串比較時小於“4”,“5”或“6”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM