{
  "id": "transactions",
  "title": "Search commands in MULTI/EXEC transactions and Lua scripts",
  "url": "https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/transactions/",
  "summary": "How Redis Search commands behave inside MULTI/EXEC transactions and Lua scripts",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-05-26T09:29:27-05:00",
  "page_type": "content",
  "content_hash": "cb0a408105745e92875b67d8263a73433bdf0e69a03db894129e7e8f56bee3aa",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis Search commands ([`FT.SEARCH`](https://redis.io/docs/latest/commands/ft.search),\n[`FT.AGGREGATE`](https://redis.io/docs/latest/commands/ft.aggregate),\n[`FT.HYBRID`](https://redis.io/docs/latest/commands/ft.hybrid),\n[`FT.PROFILE`](https://redis.io/docs/latest/commands/ft.profile), and\n[`FT.CURSOR READ`](https://redis.io/docs/latest/commands/ft.cursor-read))\ncan be used inside [`MULTI`](https://redis.io/docs/latest/commands/multi)/[`EXEC`](https://redis.io/docs/latest/commands/exec)\ntransactions and [Lua scripts](https://redis.io/docs/latest/develop/programmability/lua-api),\nbut the behavior differs depending on your deployment topology."
    },
    {
      "id": "standalone-and-single-shard-deployments",
      "title": "Standalone and single-shard deployments",
      "role": "content",
      "text": "Query commands inside a `MULTI`/`EXEC` block or Lua script (including when issued\nthrough a client pipeline that wraps commands in a transaction) execute synchronously\non the main Redis thread, regardless of the\n[`search-workers`](https://redis.io/docs/latest/develop/ai/search-and-query/administration/configuration#search-workers)\nsetting.\n\nThe worker thread pool is bypassed in this context because Redis transactions\nrequire all commands to complete sequentially without yielding to other clients.\nAs a result, queries inside transactions do not benefit from the parallelism\nprovided by `search-workers > 0`, but they execute correctly and return results\nas expected."
    },
    {
      "id": "multi-shard-deployments-oss-cluster-and-redis-software-with-multiple-shards",
      "title": "Multi-shard deployments (OSS Cluster and Redis Software with multiple shards)",
      "role": "content",
      "text": "Redis Search commands inside a `MULTI`/`EXEC` block or a Lua script are rejected with\nthe following error:\n\n[code example]\n\nThis is because the coordinator must fan out the query to multiple shards and\ncollect results asynchronously, which is incompatible with the sequential\nexecution model of transactions. This limitation applies regardless of the\n`search-workers` setting."
    },
    {
      "id": "related-commands",
      "title": "Related commands",
      "role": "related",
      "text": "- [`FT.SEARCH`](https://redis.io/docs/latest/commands/ft.search)\n- [`FT.AGGREGATE`](https://redis.io/docs/latest/commands/ft.aggregate)\n- [`FT.HYBRID`](https://redis.io/docs/latest/commands/ft.hybrid)\n- [`FT.PROFILE`](https://redis.io/docs/latest/commands/ft.profile)\n- [`FT.CURSOR READ`](https://redis.io/docs/latest/commands/ft.cursor-read)\n- [`MULTI`](https://redis.io/docs/latest/commands/multi)\n- [`EXEC`](https://redis.io/docs/latest/commands/exec)"
    }
  ],
  "examples": [
    {
      "id": "multi-shard-deployments-oss-cluster-and-redis-software-with-multiple-shards-ex0",
      "language": "plaintext",
      "code": "Cannot perform FT.SEARCH: Cannot block",
      "section_id": "multi-shard-deployments-oss-cluster-and-redis-software-with-multiple-shards"
    }
  ]
}
