Toggle Menu
Prev Up Next

# `langchain_community.vectorstores.redis.filters`.RedisFilterExpression

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

  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

    - _filter (Optional[str]) –

    - operator (Optional[RedisFilterOperator]) –

    - left (Optional[RedisFilterExpression]) –

    - right (Optional[RedisFilterExpression]) –

  __init__(_filter: Optional[str] = None, operator: Optional[RedisFilterOperator] = None, left: Optional[RedisFilterExpression] = None, right: Optional[RedisFilterExpression] = None)
    Parameters

      - _filter (Optional[str]) –

      - operator (Optional[RedisFilterOperator]) –

      - left (Optional[RedisFilterExpression]) –

      - right (Optional[RedisFilterExpression]) –

  static format_expression(left: RedisFilterExpression, right: RedisFilterExpression, operator_str: str) → str
    Parameters

      - left (RedisFilterExpression) –

      - right (RedisFilterExpression) –

      - operator_str (str) –

    Return type

      str