How do you write a RedisSearch query that combines full text search with a numeric range filter?
Short answer
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…
Advertisement
AModel answer
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.
Example
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.
Likely 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?
Related topics