如何从REST API端点提取超过10,000个ElasticSearch结果

7lrncoxx  于 2023-10-17  发布在  ElasticSearch
关注(0)|答案(1)|浏览(113)

我有一个POST API REST端点:
https://api.qa.my-server.com/abc/def/order/_startScroll?offset=0&limit=10000&fields=
点击ElasticSearch服务器。在JSON body中,我们传递以下内容:

{
    "@type": "SearchDetails",
    "@baseType": "SearchDetails",
    "@schemaLocation": "",
    "name": "myStuff",
    "filter": [
        {
            "@type": "FilterGroup",
            "@baseType": "FilterGroup",
            "@schemaLocation": "",
            "filter": [
                {
                    "@type": "AttributeFilter",
                    "@baseType": "AttributeFilter",
                    "@schemaLocation": "",
                    "field": "source.sourceSystemId",
                    "value": [
                        "test"
                    ],
                    "operator": "eq",
                    "caseInsensitive": "true"
                },
                {
                    "@type": "AttributeFilter",
                    "@baseType": "AttributeFilter",
                    "@schemaLocation": "",
                    "field": "lastUpdated",
                    "value": [
                        "2023-05-06T16:35:00"
                    ],
                    "operator": "gte",
                    "caseInsensitive": "true"
                }
            ],
            "groupOperator": "AND",
            "groupModifier": "null"
        }
    ],
    "sort": [
        {
            "field": "source.orderDate",
            "direction": "DESC"
        }
    ]
}

这个搜索查询只返回10,000个elasticsearch请求,这是最大限制,我想使用滚动或其他东西来检索所有结果(大约有1,000,000个结果)。
API端点具有参数limit,该参数基本上是结果集的大小。

qvk1mo1f

qvk1mo1f1#

您应该设置索引设置:

"max_result_window": 1000000

出于性能原因,不建议使用此方法。这定义了根据from和size参数检索的最大文档数(from + size不能高于使用的设置)

相关问题