Using RedisNum Filter Fields in LangChain
Posted: Feb 10, 2025.
Redis vector store offers powerful filtering capabilities when performing similarity searches. In this guide, we'll explore how to use the RedisNum filter field to handle numeric data in your vector store.
What is RedisNum?
RedisNum is a filter field class in LangChain that represents numeric fields in a Redis index. It allows you to define numeric fields that can be used for filtering vector search results based on numerical values. This is particularly useful when you need to filter documents based on numeric metadata like timestamps, prices, or any other numerical attributes.
Reference
Method | Description |
---|---|
init(field: str) | Initializes a RedisNum filter field with the given field name |
equals(other: RedisFilterField) -> bool | Compares this RedisNum field with another RedisFilterField for equality |
How to use RedisNum
Basic Initialization
To use RedisNum, you first need to define it as part of your Redis index schema:
Using with Vector Store Filtering
You can use RedisNum fields to filter your vector searches:
Complex Numeric Filters
RedisNum supports various numeric operations for filtering:
Using with Metadata
When adding documents to your vector store, you can include numeric metadata that corresponds to your RedisNum fields:
RedisNum is a powerful tool for handling numeric data in your Redis vector store indexes. By properly defining numeric fields and using them in filters, you can create sophisticated search queries that combine semantic similarity with numeric constraints.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.