Redis Search

Redis index is a powerful and efficient search engine that allows you to search for documents in a Redis database. It is based on the open-source search engine RediSearch. It is a powerful and efficient search engine that allows you to search for documents in a Redis database. It is based on the open-source search engine RediSearch.

Creating an index

To create an index, you need to use the FT.CREATE command. This command takes the name of the index, the schema of the index, and the configuration of the index as arguments. The schema of the index is a list of fields that you want to index, and the configuration of the index is a list of options that you want to set for the index.

Just two commands

FT.CREATE

FT.CREATE is the command that creates an index in Redis. It takes the name of the index, the schema of the index, and the configuration of the index as arguments. The schema of the index is a list of fields that you want to index, and the configuration of the index is a list of options that you want to set for the index.

Here is a detailed example on how to use it in Python:

import redis
from redis.exceptions import ResponseError

r = redis.StrictRedis(host='localhost', port=6379, db=0)

try:
    r.execute_command('FT.CREATE', 'idx', 'ON', 'HASH', 'SCHEMA', 'title', 'TEXT', 'body', 'TEXT')
except ResponseError as e:
    print(e)




FT.SEARCH

FT.SEARCH is the command that searches for documents in an index. It takes the name of the index, the query to search for, and the options for the search as arguments. The query to search for is a string that contains the search query, and the options for the search are a list of options that you want to set for the search.