# Server 端篩選

本頁說明 `entries`、`keys`、`vsearch` 如何在 server 端先篩選與分頁，再把結果送過 socket。

## Server 端篩選

| op | 規則 |
|---|---|
| `entries` | `pattern` 必填。`contains` 對原始值做不分大小寫的子字串比對。`after` 保留 `updated_at`（或 `created_at`）`>= after` 的項目。`limit <= 0` 視為 `100`；依鍵的字典序保留**最後** `limit` 筆 |
| `keys` | `pattern` 必填。`limit <= 0` 回傳全部鍵且 `page = 1`；正數 `limit` 回傳第 `max(page, 1)` 頁，且不設上限 |
| `vsearch` | `pattern` 與非空白 `text` 必填。`limit <= 0` 視為 `100` |

篩選留在 server 端，掃描時就不必把整個資料庫搬過 socket。

每個請求都建立新的 `Session` 並呼叫 `Select(db)`，因為 session 的選定資料庫是無鎖 `int`，共用狀態會讓併發請求落到錯的資料庫。

## 相關頁面

- [傳輸協定](/zh/socket-daemon-protocol)
- [掃描與 KEYS](/zh/querying)
- [VSEARCH 與 VSIM](/zh/vector-search-query)
