Quick start

Get started with search and query

Make sure that you have Redis Stack installed and running. Alternatively, you can create a free Redis Cloud account, which includes access to all Redis Stack features.


This quick start guide will demonstrate how to:

  • Create a secondary index.
  • Load JSON data into Redis.
  • Perform simple searches on the indexed data.

The data is a simple bicycle inventory consisting of a JSON array, where each element has the following structure:

  "brand": "brand name",
  "condition": "new | used | refurbished",
  "description": "description",
  "model": "model",
  "price": 0

Connect to Redis Stack

Create an index

The Redis keyspace is unstructured and flat. As such, you can only access data by primary key (keyname), making it cumbersome to find a document based on a secondary characteristic, such as finding a school by name or listing all schools in a particular city. Redis Stack addresses this need by providing the ability to add secondary indexes to your data. Redis currently supports secondary index creation on the HASH and JSON data types.

Use the following FT.CREATE command to create an index with fields and weights, where the default weight is 1.0. Note how each term of the SCHEMA is an element of a JSON object, identified by its JSONPath.

Any pre-existing JSON documents that have a key prefixed with bicycle: are automatically added to the index after it is created. Additionally, any JSON documents with the same prefix that are created after index creation are also added to the index.

Add JSON documents

Use the JSON.SET command to create new JSON documents.

Search the data using the index

Wildcard query

Retrieve all indexed documents using the FT.SEARCH command. Note the use of the LIMIT clause below, which provides for search result pagination.

Single-term query

Use the following command to perform a simple, single-term query, such as finding all bicycles with a specific model: