RediSearch - Wildcard queries return *99 records

Hi,

I am using ioredis to run a metrics interval function that executes two queries against Redis. I am using sentinel with one master and two slave nodes and this metric function always connects to a slave node. RediSearch version v2.6.5.

const dbSize = await redis.dbsize();
const indexSize = await redis.call("FT.SEARCH", "devices", "*", "LIMIT", 0, 0);

The first query never has an issue, but occasionally the FT.SEACH query will return a record ending with 99 (eg. 399 or 199). The two queries should always match but randomly we get a bad response from the FT.SEARCH and when it starts happening it’s not 100%.

I have noticed that re-building the index temporarily solves this issue but I am not sure what the source of the issue is since there are no records in Redis that do not have all the required indexed fields.
Is the *99 response a signal when we hit a Redis Global Lock or is the RediSearch query running into an issue?
If it is a concurrency issue, are there any docs/ examples you can point me to so I can detect/ avoid any potential querying issues?

Thanks

100n + 99 is a common pattern when the query times out, as RediSearch checks for timeout every 100 documents. The default timeout time is 500 milliseconds and the default timeout behavior is to return whatever results the module retrieved.
If you set the default timeout time to a low value, such query may not be able to finish.
If all you’re trying to do is to get the number of documents in the index, you can try using FT.INFO instead of a wildcard and limit 0 0, as such query will scan the entire index to count the number of documents.