Faceted search in Redis Cloud enables real-time filtering and grouping of search results by attributes such as category, brand, and color, making it well suited for catalogs, analytics, and search-driven UIs. Redis Cloud implements faceted search through the Redis Search module, which provides synchronous indexing and fast aggregations with FT.SEARCH and FT.AGGREGATE.
This article explains how faceted search works in Redis Cloud, provides example schemas and queries for common patterns, and includes troubleshooting guidance for index, schema, and aggregation issues.
Quick Fix Table
| Symptom | Likely Cause | Recommended Action |
|---|---|---|
| Aggregation counts missing or incorrect | Schema mismatch or unindexed data | Run FT.INFO <index> and check for hash_indexing_failures
|
| No results returned for facet filter | Field not defined as TAG | Redefine field as TAG; TEXT fields cannot be filtered |
| Performance slow for large datasets | Too many unfiltered results | Use SORTBY and LIMIT in aggregation queries |
FT.AGGREGATE not recognized |
Module unavailable or disabled | Verify Redis Cloud plan includes Redis Search |
| Unexpected facet groupings | Multi-value field not split | Use APPLY "split(@field)" AS field before GROUPBY
|
Implementing Faceted Search in Redis Cloud
Faceted search is implemented using TAG fields in a Redis Search index and aggregation queries to group and count documents by facet.
Example
Create Index
FT.CREATE product_idx ON JSON PREFIX 1 product: SCHEMA \ $.Name AS name TEXT \ $.Brand AS brand TAG SORTABLE \ $.Color AS color TAG SORTABLE
Insert Data
JSON.SET product:1 $ '{"Name":"Classic loafers", "Brand":"Santoni", "Color":"brown"}'
JSON.SET product:2 $ '{"Name":"Running shoes", "Brand":"Adidas", "Color":"black"}'Get Document Count per Facet
FT.AGGREGATE product_idx * GROUPBY 1 @color REDUCE COUNT 0 AS num SORTBY 2 @num DESC
Filter by Facet
FT.SEARCH product_idx '@color:{brown}' RETURN 2 name brandCombine Full-text and Facet Filters
FT.SEARCH product_idx 'leather @brand:{Santoni}'Troubleshooting Common Issues
| Issue | Cause | Resolution |
|---|---|---|
| Facet counts missing | Index not fully built | Wait until FT.INFO shows indexing: 0
|
| Aggregation returns duplicates | Multi-value fields not split | Add APPLY "split(@field)" AS field before GROUPBY
|
| Facet filter returns no data | Field type TEXT instead of TAG | Use TAG for all facet fields |
| Search is extremely slow | No LIMIT or selective grouping |
Add LIMIT and selective filters |
| Module unavailable | Search module not included in plan | Upgrade to Redis Cloud Pro or above |
FAQs
Can I use JSON documents for faceted search in Redis Cloud?
Yes. Redis Search supports both Hashes and JSON documents via the ON JSON schema option.
Can I combine faceted filters and full-text search?
Yes. You can combine textual search terms and facet filters in a single FT.SEARCH query.
Are aggregations real-time?
Yes. Redis recalculates aggregations on each query, allowing real-time facet updates.
0 comments
Please sign in to leave a comment.