- Open Postman, create a new GET request, and enter the request URL:
http://localhost:9200/item_wunsche/_search
- Select the Body tab, select raw and JSON format in the request body, and enter the following query conditions:
{
"query": {
"match_all": {}
}
}
-
Send a request and you will get results for all documents in the item_wunsche index. You can use the scroll API to obtain data in pages, but you need to obtain the scroll_id through the search API first. The following is an example of pagination query using the scroll API:
-
Create a new POST request, and enter the request URL:
http://localhost:9200/item_wunsche/_search?scroll=1m
//该请求体中的"scroll": "1m"表示scroll游标的失效时间为1分钟。
- Select raw in the request body and select the JSON format, and enter the following query conditions:
{
"query": {
"match_all": {}
},
"size": 1000
}
-
Send a request, and you will get the first 1000 items in the item_wunsche index and a scroll_id.
-
Copy the scroll_id and create a new POST request, and enter the request URL:
http://localhost:9200/_search/scroll
- Select raw in the request body and select the JSON format, and enter the following query conditions:
{
"scroll": "1m",
"scroll_id": "<您在上一步中复制的scroll_id>"
}
-
Send a request, you will get 1001 to 2000 data in the item_wunsche index and a new scroll_id.
-
Repeat steps 5 and 6 until all data is acquired.
It should be noted that when using the scroll API, all paging queries must be completed within a certain period of time, otherwise the scroll cursor will become invalid.