The error message:
(error) idx:movie: no such index
means that the RediSearch index named idx:movie does not exist in your Redis instance.
Why?
Before you can use the FT.SEARCH command, you must create an index with FT.CREATE. The index tells RediSearch how to interpret your data and which fields to index.
How to Fix
You need to create the index. Based on your hash structure (e.g., movie:1), you can create an index like this:
FT.CREATE idx:movie ON HASH PREFIX 1 movie: SCHEMA \
movie_name TEXT \
release_year NUMERIC \
rating NUMERIC \
votes NUMERIC \
category TAG \
plot TEXT \
imdb_id TAG
ON HASHtells RediSearch to index hashes.PREFIX 1 movie:means index all hashes with keys starting withmovie:.SCHEMAdefines the fields and their types.
Steps
- Connect to your Redis instance (on port 6380).
- Run the FT.CREATE command above.
- Try your FT.SEARCH command again:
FT.SEARCH idx:movie "@release_year:[1995 2020]" RETURN 2 movie_name release_year
Summary
You must create the RediSearch index before searching. Once the index is created, your search command will work as expected.
Let me know if you need help with the exact FT.CREATE command for your data!