RedisFilterExpression#

class langchain_community.vectorstores.redis.filters.RedisFilterExpression(_filter: str | None = None, operator: RedisFilterOperator | None = None, left: RedisFilterExpression | None = None, right: RedisFilterExpression | None = None)[source]#

Logical expression of RedisFilterFields.

RedisFilterExpressions can be combined using the & and | operators to create complex logical expressions that evaluate to the Redis Query language.

This presents an interface by which users can create complex queries without having to know the Redis Query language.

Filter expressions are not initialized directly. Instead they are built by combining RedisFilterFields using the & and | operators.

Examples

>>> from langchain_community.vectorstores.redis import RedisTag, RedisNum
>>> brand_is_nike = RedisTag("brand") == "nike"
>>> price_is_under_100 = RedisNum("price") < 100
>>> filter = brand_is_nike & price_is_under_100
>>> print(str(filter))
(@brand:{nike} @price:[-inf (100)])

Methods

__init__([_filter, operator, left, right])

format_expression(left, right, operator_str)

Parameters:
__init__(_filter: str | None = None, operator: RedisFilterOperator | None = None, left: RedisFilterExpression | None = None, right: RedisFilterExpression | None = None)[source]#
Parameters:
static format_expression(left: RedisFilterExpression, right: RedisFilterExpression, operator_str: str) str[source]#
Parameters:
Return type:

str