Unknown Command FT.CREATE when creating an index for Redis – Redis

by
Ali Hasan
llama-cpp-python redis redis-py

Quick Fix: Consider using Redis Stack for an effortless setup with pre-configured search and JSON modules. Alternatively, compile and install the necessary modules yourself by editing the Redis configuration file.

The Problem:

When trying to utilize a Redis command to create an index in Python, the error message "unknown command FT.CREATE" is encountered. Removing the create index lines results in a different error related to Path.root_path(). The root cause and a solution for these errors need to be determined.

The Solutions:

Solution 1: Use a Redis Stack Instance

To resolve the "unknown command FT.CREATE" error encountered when creating an index for Redis, consider using a Redis Stack instance. Redis Stack is a managed Redis service that includes pre-configured modules such as RediSearch and RedisJSON, which are required for indexing and querying JSON documents. By using a Redis Stack instance, you can easily set up the necessary modules and avoid installation and configuration issues.

You can obtain a Redis Stack instance from the following link:

https://redis.io/docs/getting-started/install-stack/

Using a Redis Stack instance offers several advantages:

  • It provides a straightforward approach to utilizing RediSearch and RedisJSON modules.
  • The modules are pre-configured, eliminating the need for manual installation and configuration.
  • It allows you to quickly set up a Redis instance with the necessary modules.

Alternatively, you can consider compiling the search module (and potentially JSON if required) yourself from the source code and installing them into your existing Redis server by modifying its configuration file. However, this approach is more complex and requires technical expertise.

For more information, refer to the following resources:

Q&A

What’s the difference between using Redis Stack and compiling RediSearch module?

Using Redis Stack is more straightforward, while compiling RediSearch module requires manual configuration.

Where can I get Redis Stack?

You can get Redis Stack from https://redis.io/docs/getting-started/install-stack/

What other module do I need to store JSON natively and search over that?

You also need the JSON module from https://github.com/RedisJSON/RedisJSON

Video Explanation:

The following video, titled "Adding Secondary Indexes to Existing Redis Data with RediSearch ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

RediSearch makes it easy to query and index your Redis data. Andrew demonstrates how to add a RediSearch index to an existing Redis database ...