简体   繁体   English

如何在范围查询中应用分页来获取完整记录?

[英]how to apply pagination in the range query to get full records?

I am trying to apply pagination to my range query to get full records between the given date range.我正在尝试将分页应用于我的范围查询以获取给定日期范围之间的完整记录。

Below is the query i tried using以下是我尝试使用的查询

Query :查询

   {
        "query": 
        {
            "range": 
            {
                "sys_created_on": 
                    {
                        "gte":"2022-01-01 01:00:00", 
                        "lte":"2022-03-10 01:00:00"
                    }
            }
        },
        "sort": [
            {"sys_created_on": "asc","u_user_updated": "asc"}
            ]
    }

payload :有效载荷

    {
        "took": 62,
        "timed_out": false,
        "_shards": {
            "total": 8,
            "successful": 8,
            "skipped": 0,
            "failed": 0
        },
        "hits": {
            "total": {
                "value": 10000,
                "relation": "gte"
            },
            "max_score": null,
            "hits": [
                {
                    "_type": "_doc",
                    "_id": "61c158191bbc89905ad62064604bcb39",
                    "_score": null,
                    "_source": {
               "key1":"val1",
                "key2":"val2",
                --------
                --------
                "keyn":"valn",
}
                }
        }

In the above query "sys_created_on" and "u_user_updated" are the fields available in my payload response.在上述查询中,“sys_created_on”和“u_user_updated”是我的有效负载响应中可用的字段。 As said in this documentation, [elastic_search_search_query] , I am not getting the payload with "sort" as key.如本文档[elastic_search_search_query]中所述,我没有以“排序”为键获取有效负载。 So that I can use the search_after这样我就可以使用search_after

Try changing尝试改变

"sort": [
        {"sys_created_on": "asc","u_user_updated": "asc"}
        ]

for为了

"sort": [
        {"sys_created_on": "asc"}, {"u_user_updated": "asc"}
        ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM