HYBRIDfields are indexed for both full-text and semantic search.- Retrievers run the searches.
$annruns a semantic search, and$rrfmerges the results of several retrievers into one list.
Hybrid fields
AHYBRID field is a TEXT field that also stores a vector embedding. Full-text queries work on it
the same way as on a TEXT field, and $ann searches its embeddings by meaning. See
Hybrid Fields for the field options.
- An index can have more than one
HYBRIDfield. - If the text of a document cannot be embedded, the document is still searchable by its text.
HYBRIDfields work with JSON, hash, string, and stream indexes.
How embeddings are created
You don’t create vectors yourself. You don’t need your own embedding provider, an API key, or a separate vector database. Redis Search creates the embeddings for you:- When you write a document, Search sends the text of its
HYBRIDfields to an OpenAI embedding model (one oftext-embedding-3-smallortext-embedding-3-large) in the background and stores the returned vectors in the index. - When you run an
$annquery, Search creates an embedding of the query text with the same model and finds the documents with the closest vectors.
The text of
HYBRID fields and of $ann queries is sent to OpenAI to create embeddings. Use TEXT
instead of HYBRID for fields whose content must not be sent to a third party.Pricing
Hybrid search has no extra cost, and creating embeddings is included. Commands are billed the same way as all other Redis commands, whether the index hasHYBRID fields or not. See Pricing.
Create an index
Declare the fields you want to search by meaning asHYBRID:
- TypeScript
- Python
- Redis CLI
Add documents
Write documents as usual. Search indexes them and creates their embeddings:- TypeScript
- Python
- Redis CLI
Search by meaning
Use$ann to find the documents that are closest in meaning to a
text. This query can find the earplugs, even though their description does not contain the word
“noise”:
- TypeScript
- Python
- Redis CLI
Combine full-text and semantic search
Use$rrf to run a full-text query and a semantic search, and merge
their results into one list. Documents that rank high in both come first:
- TypeScript
- Python
- Redis CLI
$standard:
- TypeScript
- Python
- Redis CLI
Next steps
- See Retrievers for all retriever parameters and rules.
- See Schema Definition for field types and options.
- See
SEARCH.QUERYfor all query options.