FT.CURSOR

Since 1.1.0Search

Syntax

FT.CURSOR
  • ACL categories: @read, @search, @slow
  • Arity: -1

FT.CURSOR is a container: its subcommands read and close the cursors that FT.AGGREGATE ... WITHCURSOR opens, so that a large aggregation can be read a page at a time instead of in one reply.

Subcommand
FT.CURSOR READthe next rows, and the cursor to read on with (0 at the end)
FT.CURSOR DELclose a cursor before it is read to the end
FT.CURSOR GCdrop the cursors left unread longer than they may be, and return how many

A cursor holds the rows the aggregation produced when it ran. It is closed when it is read to the end, deleted, left unread longer than its MAXIDLE (at most CURSOR_MAX_IDLE, 300000 ms by default; see FT.CONFIG), or when its index is dropped. Idle cursors are dropped whenever any cursor is used, so FT.CURSOR GC is seldom needed. At most 1024 cursors can be open at once; past that, FT.AGGREGATE ... WITHCURSOR fails with Too many cursors allocated for index. In a cluster, the cursor is kept on the node the aggregation was sent to.

Name the index the cursor was opened on, by its own name: an alias is not accepted.

Examples

> FT.CURSOR
(error) ERR wrong number of arguments for 'FT.CURSOR' command
> FT.CURSOR NOPE
(error) Unknown subcommand
> FT.CURSOR GC products
(integer) 0

Subcommands

  • FT.CURSOR DEL: Closes a cursor opened by FT.AGGREGATE ... WITHCURSOR before it has been read to the end, and frees the rows it holds.
  • FT.CURSOR READ: Returns the next rows of an aggregation started with WITHCURSOR, COUNT n at a time, and the cursor to read on with: 0 once there are no more, and the cursor is closed.