From d904601df7e4f23f815a3c7b37ff6d4f3c49f5b3 Mon Sep 17 00:00:00 2001 From: Joey Whelan Date: Mon, 16 Sep 2024 11:19:30 -0600 Subject: [PATCH 1/2] add note regarding LIMIT behavior --- content/commands/ft.search/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/commands/ft.search/index.md b/content/commands/ft.search/index.md index 5e6055cc66..366debed01 100644 --- a/content/commands/ft.search/index.md +++ b/content/commands/ft.search/index.md @@ -478,6 +478,8 @@ orders the results by the value of this attribute. This applies to both text and LIMIT first num limits the results to the offset and number of results given. Note that the offset is zero-indexed. The default is 0 10, which returns 10 items starting from the first result. You can use `LIMIT 0 0` to count the number of documents in the result set without actually returning them. + +**Limit behavior**: If no sorting is done, `LIMIT` results are non-deterministic. This means it may return results that are duplicated or missing in subsequent queries. To ensure deterministic result set paging, you can add `SORTBY` with a unique field or use `FT.AGGREGATE` and `WITHCURSOR`.
From fa37ea0f1eaf3a70db6ca0224603631518685a42 Mon Sep 17 00:00:00 2001 From: David Dougherty Date: Tue, 17 Sep 2024 06:59:17 -0700 Subject: [PATCH 2/2] Update content/commands/ft.search/index.md --- content/commands/ft.search/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/commands/ft.search/index.md b/content/commands/ft.search/index.md index 366debed01..cfcddeeb45 100644 --- a/content/commands/ft.search/index.md +++ b/content/commands/ft.search/index.md @@ -479,7 +479,7 @@ orders the results by the value of this attribute. This applies to both text and limits the results to the offset and number of results given. Note that the offset is zero-indexed. The default is 0 10, which returns 10 items starting from the first result. You can use `LIMIT 0 0` to count the number of documents in the result set without actually returning them. -**Limit behavior**: If no sorting is done, `LIMIT` results are non-deterministic. This means it may return results that are duplicated or missing in subsequent queries. To ensure deterministic result set paging, you can add `SORTBY` with a unique field or use `FT.AGGREGATE` and `WITHCURSOR`. +**`LIMIT` behavior**: If you use the `LIMIT` option without sorting, the results returned are non-deterministic, which means that subsequent queries may return duplicated or missing values. Add `SORTBY` with a unique field, or use `FT.AGGREGATE` with the `WITHCURSOR` option to ensure deterministic result set paging.