Skip to content

Commit efffa39

Browse files
committed
DEV: document search limitation inside MULTI/EXEC
1 parent 6c058d7 commit efffa39

File tree

7 files changed

+70
-2
lines changed

7 files changed

+70
-2
lines changed

content/commands/ft.aggregate.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,4 @@ One of the following:
529529
- [Aggregations]({{< relref "/develop/ai/search-and-query/advanced-concepts/aggregations" >}})
530530
- [Key and field expiration behavior]({{< relref "/develop/ai/search-and-query/advanced-concepts/expiration" >}})
531531
- [RediSearch]({{< relref "/develop/ai/search-and-query" >}})
532+
- [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})

content/commands/ft.cursor-read.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,5 @@ One of the following:
101101

102102
## Related topics
103103

104-
[RediSearch]({{< relref "/develop/ai/search-and-query/" >}})
104+
- [RediSearch]({{< relref "/develop/ai/search-and-query/" >}})
105+
- [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})

content/commands/ft.hybrid.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,4 @@ One of the following:
823823

824824
- [Vector search concepts]({{< relref "/develop/ai/search-and-query/vectors" >}})
825825
- [Combined search]({{< relref "/develop/ai/search-and-query/query/combined/" >}})
826+
- [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})

content/commands/ft.profile.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,5 +464,6 @@ One of the following:
464464

465465
## Related topics
466466

467-
[RediSearch]({{< relref "/develop/ai/search-and-query/" >}})
467+
- [RediSearch]({{< relref "/develop/ai/search-and-query/" >}})
468+
- [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})
468469

content/commands/ft.search.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,3 +883,4 @@ One of the following:
883883
- [Key and field expiration behavior]({{< relref "/develop/ai/search-and-query/advanced-concepts/expiration" >}})
884884
- [Query syntax]({{< relref "/develop/ai/search-and-query/query/" >}})
885885
- [RediSearch]({{< relref "/develop/ai/search-and-query/" >}})
886+
- [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})

content/develop/ai/search-and-query/advanced-concepts/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Redis Open Source supports the following Redis Search features. This article pro
4545
* Geo-filtering using Redis [geo commands]({{< relref "/commands/" >}}?group=geo)
4646
* [Vector search]({{< relref "/develop/ai/search-and-query/vectors" >}})
4747
* [Key and field expiration behavior]({{< relref "/develop/ai/search-and-query/advanced-concepts/expiration" >}})
48+
* [Search commands in MULTI/EXEC transactions and Lua scripts]({{< relref "/develop/ai/search-and-query/advanced-concepts/transactions" >}})
4849

4950

5051
## Full-text search features
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
categories:
3+
- docs
4+
- develop
5+
- stack
6+
- oss
7+
- rs
8+
- rc
9+
- oss
10+
- kubernetes
11+
- clients
12+
description: How Redis Search commands behave inside MULTI/EXEC transactions and Lua scripts
13+
linkTitle: Search in transactions
14+
title: Search commands in MULTI/EXEC transactions and Lua scripts
15+
weight: 36
16+
---
17+
18+
Redis Search commands ([`FT.SEARCH`]({{< relref "/commands/ft.search" >}}),
19+
[`FT.AGGREGATE`]({{< relref "/commands/ft.aggregate" >}}),
20+
[`FT.HYBRID`]({{< relref "/commands/ft.hybrid" >}}),
21+
[`FT.PROFILE`]({{< relref "/commands/ft.profile" >}}), and
22+
[`FT.CURSOR READ`]({{< relref "/commands/ft.cursor-read" >}}))
23+
can be used inside [`MULTI`]({{< relref "/commands/multi" >}})/[`EXEC`]({{< relref "/commands/exec" >}})
24+
transactions and [Lua scripts]({{< relref "/develop/programmability/lua-api" >}}),
25+
but the behavior differs depending on your deployment topology.
26+
27+
## Standalone and single-shard deployments
28+
29+
Redis Search commands inside a `MULTI`/`EXEC` block or a Lua script execute synchronously
30+
on the main Redis thread, regardless of the
31+
[`search-workers`]({{< relref "/develop/ai/search-and-query/administration/configuration#search-workers" >}})
32+
setting.
33+
34+
The worker thread pool is bypassed in this context because Redis transactions
35+
require all commands to complete sequentially without yielding to other clients.
36+
As a result, queries inside transactions do not benefit from the parallelism
37+
provided by `search-workers > 0`, but they execute correctly and return results
38+
as expected.
39+
40+
## Multi-shard deployments (OSS Cluster and Redis Software with multiple shards)
41+
42+
Redis Search commands inside a `MULTI`/`EXEC` block or a Lua script are rejected with
43+
the following error:
44+
45+
```
46+
Cannot perform FT.SEARCH: Cannot block
47+
```
48+
49+
This is because the coordinator must fan out the query to multiple shards and
50+
collect results asynchronously, which is incompatible with the sequential
51+
execution model of transactions. This limitation applies regardless of the
52+
`search-workers` setting.
53+
54+
## Related commands
55+
56+
- [`FT.SEARCH`]({{< relref "/commands/ft.search" >}})
57+
- [`FT.AGGREGATE`]({{< relref "/commands/ft.aggregate" >}})
58+
- [`FT.HYBRID`]({{< relref "/commands/ft.hybrid" >}})
59+
- [`FT.PROFILE`]({{< relref "/commands/ft.profile" >}})
60+
- [`FT.CURSOR READ`]({{< relref "/commands/ft.cursor-read" >}})
61+
- [`MULTI`]({{< relref "/commands/multi" >}})
62+
- [`EXEC`]({{< relref "/commands/exec" >}})

0 commit comments

Comments
 (0)