FT.AGGREGATE Strange Behavior

I’m trying to migrate our redisearch queries from FT.SEARCH to FT.AGGREGATE. But I’m having problems with running them:

FT.SEARCH idx * returns all our records for an index just fine, but after simply changing it to FT.AGGREGATE idx *, it just returns a 1 and empty arrays, which is strange - what does the 1 mean and why are all arrays now empty:

1) (integer) 1
2) (empty array)
3) (empty array)
4) (empty array)
5) (empty array)
6) (empty array)
7) (empty array)
8) (empty array)
9) (empty array)

When using FT.AGGREGATE idx * WITHCURSOR COUNT 3, it returns:

1) 1) (integer) 1
   2) (empty array)
   3) (empty array)
   4) (empty array)
2) (integer) <cursor>

But then I do FT.CURSOR READ idx <cursor>, I get: Error: Server closed the connection, but I’m sure the cursor should not have timed out yet

Hi Cheng,

FT.AGGREGATE does not load any fields by default. You can use LOAD to add fields you wish to return or you can use LOAD * to load all fields.

Can you please share more info about the cursor? the error you report might be a server crash. What version of redis and redisearch are you using?

Hi,

Adding load * returns an error like this, what’s the right way to get all fields back?

FT.AGGREGATE idx * LOAD *
(error) Bad arguments for LOAD: Could not convert argument to expected type

I’m using: Redis server v=6.2.6 and redis-cli 6.2.6

@cheng what version of RediSearch are you using?

It should be RediSearch 2 v 2.0.6
and Redis version 6.0.6

@cheng LOAD * was added in 2.0.13.
The latest version is 2.2.10

Got it thanks. Is the FT.CURSOR READ error also version related? e.g.

> FT.AGGREGATE idx * LOAD 1 name WITHCURSOR COUNT 3
1) 1) (integer) 1
   2) 1) "name"
      2) "test3"
   3) 1) "name"
      2) "test4"
   4) 1) "name"
      2) "test2"
2) (integer) <cursor>
> FT.CURSOR READ idx <cursor>
Error: Server closed the connection

Do you get <cursor> in the reply? You should get a number.

Error: Server closed the connection - did your server crash? If so, can you please provide us with the full crash report?

Yes, I got the cursor and used it. I don’t see a crash in the server log, but I ran the same thing to another db using Redis version 6.2.3 and RediSearch 2 v 2.0.11, and the error went away. So I think it’s a version-related issue.

Good to hear the cursor is working for you now.
I have tried recreating the issue with v2.0.6 without success.
Can you provide further details about reproducing the issue?

Hm sure, I ran redis server, and then redis-cli, went through auth, then these commands-

> FT.AGGREGATE idx * LOAD 1 name WITHCURSOR COUNT 3
1) 1) (integer) 1
   2) 1) "name"
      2) "test3"
   3) 1) "name"
      2) "test4"
   4) 1) "name"
      2) "test2"
2) (integer) <cursor>
> FT.CURSOR READ idx <cursor>
Error: Server closed the connection

I don’t think there are more details to it.

But why do read docs states that the load hurts the performance of AGGREGATE queries ? I am bit confused in this.

Docs : Aggregations | Redis