RedisSearch (Full Text Search)

7 questions found

What is RedisSearch, and what capabilities does it add to a Redis deployment?

Beginner
RedisSearch adds powerful indexing and querying capabilities to Redis, letting you perform full text search, filter and sort by numeric or tag fields, and run complex queries across your data directly within Redis, capabilities that go well beyond what Redis's core commands alone can provide.
FT.CREATE idx ON HASH PREFIX 1 product: SCHEMA name TEXT price NUMERIC
FT.SEARCH idx 'laptop'
Real-world example An online store adds RedisSearch to their existing Redis deployment, gaining the ability to let customers search for products by name while also filtering by price range, all within the same Redis instance already used for caching.

Common follow-ups: Does RedisSearch work with data already stored in Redis using hashes and JSON documents?;How does search performance compare to a dedicated search engine?

RedisJSON;Redis Modules Overview

How do you create a search index in RedisSearch, and what does defining a schema for that index actually do?

Beginner
You use the FT.CREATE command, specifying which keys to index based on a prefix pattern and defining a schema that maps specific fields within your data to search field types like TEXT for full text searchable content, NUMERIC for range queries, or TAG for exact match filtering, telling RedisSearch exactly how to index and later let you query each field.
FT.CREATE product_idx ON HASH PREFIX 1 product: SCHEMA name TEXT price NUMERIC category TAG
Real-world example A product catalog defines a search index specifying that the name field should support full text search, the price field should support numeric range queries, and the category field should support exact tag based filtering.

Common follow-ups: What happens to existing data if you create an index after that data was already added?;Can you modify an existing index's schema later without recreating it?

Data Types;Hashes in Redis

How do you write a RedisSearch query that combines full text search with a numeric range filter?

Intermediate
You use the FT.SEARCH command with a query string that includes your text search terms alongside a numeric filter expression targeting a specific field, using syntax like an at sign followed by the field name and a range in square brackets, letting you combine text relevance search with precise numeric filtering in a single query.
FT.SEARCH product_idx '@name:laptop @price:[500 1500]'
Real-world example An online store lets customers search for laptops specifically within their budget range, combining a text search for the word laptop with a numeric filter restricting results to products priced between five hundred and fifteen hundred dollars.

Common follow-ups: How do you combine multiple different numeric range filters in the same query?;What happens if a document is missing the field being filtered on?

Data Types;RedisSearch (Full Text Search)

How do you sort and paginate search results returned by a RedisSearch query?

Intermediate
You add the SORTBY clause to your search query specifying the field to sort by and the direction, and use the LIMIT clause to specify a starting offset and the maximum number of results to return, letting you build a typical paginated search results experience directly using RedisSearch's built-in capabilities.
FT.SEARCH product_idx '@category:{electronics}' SORTBY price ASC LIMIT 0 20
Real-world example A product search page displays the first twenty electronics products sorted by ascending price, using RedisSearch's built-in sorting and pagination features to efficiently retrieve exactly the results needed for that specific page.

Common follow-ups: Does sorting require the field to have any special index configuration?;How do you retrieve the second page of results using the LIMIT clause?

Data Types;Redis Performance Tuning & Benchmarking

How would you design a RedisSearch based product search feature that supports faceted filtering, such as showing available categories and their counts alongside search results?

Advanced
You would use RedisSearch's aggregation capabilities through the FT.AGGREGATE command, grouping matched results by category and counting occurrences within each group, letting you display both the actual search results and a summary of available filter categories with counts, similar to what you commonly see on major e-commerce search pages.
FT.AGGREGATE product_idx '@name:laptop' GROUPBY 1 @category REDUCE COUNT 0 AS count
Real-world example An e-commerce search results page shows customers not just matching products but also a sidebar listing each available category along with how many matching products exist in each one, powered by a RedisSearch aggregation query.

Common follow-ups: What other aggregation operations does FT.AGGREGATE support besides counting?;How does aggregation performance compare to a simple search query on the same dataset?

RedisJSON;Redis Modules Overview

What are the memory and performance tradeoffs of adding RedisSearch indexes to a large existing dataset in Redis?

Advanced
Search indexes require additional memory beyond the original data itself, roughly proportional to how many fields you index and how large your text content is, and while search queries are generally very fast, indexing overhead adds to every write operation on indexed data, meaning it is important to only index the specific fields you actually need to search or filter on rather than indexing everything by default.
-- Index only the fields actually needed for search
-- rather than every single field in the document
FT.CREATE idx ON HASH PREFIX 1 doc: SCHEMA searchable_field TEXT
Real-world example A team adding RedisSearch to an existing large dataset carefully selects only the specific fields customers actually need to search or filter by, avoiding unnecessary memory overhead from indexing fields that will never actually be queried.

Common follow-ups: How much additional memory does a typical text index add relative to the original data size?;How do you measure the actual write performance impact of maintaining a search index?

Redis Memory Optimization;Redis Performance Tuning & Benchmarking

How do you update or delete a RedisSearch index without affecting the underlying data it was built from?

Intermediate
You use FT.DROPINDEX to remove an index definition, with the option to also delete the underlying documents if desired or leave them intact if you plan to recreate the index later, and to change an index's schema you typically need to drop and recreate it with the new field definitions, since RedisSearch does not support modifying an existing field's type directly.
FT.DROPINDEX product_idx
FT.CREATE product_idx ON HASH PREFIX 1 product: SCHEMA name TEXT price NUMERIC brand TAG
Real-world example A team needing to add a new searchable field to their product index drops the existing index definition and recreates it with the updated schema, while their actual underlying product data in Redis remains completely untouched throughout the process.

Common follow-ups: Does dropping an index affect the actual underlying data by default?;How long does it take to rebuild an index for a very large dataset?

Redis CLI & Basic Commands;Data Types