SEARCH.CREATE to create a search index over JSON, hash, or string values.
ON names the type of key to index and PREFIX the key prefixes to watch, so the index covers exactly the keys that match both, including keys written after it was created. The SCHEMA then declares which fields are searchable and how: TEXT fields are analyzed for full-text search, with NOSTEM and NOTOKENIZE to turn parts of that off, numeric, boolean, and date fields are matched exactly and can be marked FAST to make them usable for sorting and scoring, and KEYWORD and FACET fields are kept whole for exact matching and faceting. FROM maps a schema field to a differently named field in the document.
Creating an index starts an initial scan of the matching keys, which SKIPINITIALSCAN skips when you only want to index data written from now on; SEARCH.REINDEX can run that scan later. EXISTSOK makes the command succeed instead of failing when the index already exists.
See Index Management for a feature-level guide to creating indexes and Schema Definition for field types and schema design.
Upstash Redis Search uses
SEARCH.* commands. They are separate from and incompatible with the FT.* commands in the open-source RediSearch module.Syntax
Arguments
Schema field options
Response
Returns1 when the index is created. With EXISTSOK, returns 0 if the existing index has the same data type, prefixes, and schema. Returns an error for a different configuration or when <name> is already used by a non-index Redis key.
Examples
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
upstash_redis
upstash_redis
ioredis
ioredis
node-redis
node-redis
curl
curl