Redis use filters #17397
Replies: 1 comment 1 reply
-
🤖 Hey there @tarekabouzeid! Great to see you diving into new challenges with LangChain. How's everything going on your end? To pass filters to the Redis retriever in LangChain, you need to create instances of the Here are some examples:
from langchain_community.vectorstores.redis import RedisTag
# Create a filter where the 'brand' tag is 'nike'
filter = RedisTag("brand") == "nike"
from langchain_community.vectorstores.redis import RedisNum
# Create a filter where the 'age' is greater than 18
filter = RedisNum("age") > 18
from langchain_community.vectorstores.redis import RedisText
# Create a filter where the 'job' field contains the term 'engineer'
filter = RedisText("job") % "engineer"
from langchain_community.vectorstores.redis import RedisTag, RedisNum
# Create a filter where the 'brand' tag is 'nike' and the 'price' is less than 100
filter = (RedisTag("brand") == "nike") & (RedisNum("price") < 100) The resulting Regarding your code snippet, it seems like you're trying to pass a string as retriever = redis.as_retriever(
search_type="similarity_distance_threshold",
search_kwargs={'include_metadata': True, 'distance_threshold': 0.8, 'k': 5}
) I hope this helps! If you have any other questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
System Info
langchain 0.0.346
langchain-core 0.0.10
python 3.9.18
Beta Was this translation helpful? Give feedback.
All reactions