| 排序写法 | "sort": [ { "date": "desc" }, "_score" ] |
|---|---|
| 字段排序限制 | text 字段不能直接排序,要用 keyword 子字段 |
| 分页上限 | from + size 不超过 index.max_result_window(默认 10000) |
示例
示例
GET /my-index/_search
{
"from": 20,
"size": 10,
"sort": [
{ "publish_date": { "order": "desc", "missing": "_last" } },
{ "_score": "desc" }
],
"track_total_hits": true
}track_total_hits 默认只统计到 10000 就返回 gte,需要精确总数时显式设为 true;深分页改用 search_after。