RedisSearch get max date in JSON

Viewed 39

I use RedisSearch to query my products

I want to get last 10 products changed

In SQL I can do that with:

Select top 10 * from products order by max(changedate) desc

How can I get the same result using RedisSearch?

1 Answers

You can use a range query with sortby.

FT.SEARCH products "@changedate:[somedate inf]" SORTBY changedate DESC

Please note that the smaller the date range you give, the faster the query will execute. You can fo [-inf inf] but that will not be efficiant.

Related