From 2b54ef53a05f28edef52c6fae7bcba3ecb796de2 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Mon, 10 Jun 2024 14:15:38 -0400 Subject: [PATCH] x --- langchain_postgres/vectorstores.py | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index 659b6f32..108b1149 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -301,6 +301,41 @@ class PGVector(VectorStore): * langchain_postgres now accept async connections. If you want to use the async version, you need to set `async_mode=True` when initializing the store or use an async engine. + + Supported filter operators: + + * $eq: Equality operator + * $ne: Not equal operator + * $lt: Less than operator + * $lte: Less than or equal operator + * $gt: Greater than operator + * $gte: Greater than or equal operator + * $in: In operator + * $nin: Not in operator + * $between: Between operator + * $exists: Exists operator + * $like: Like operator + * $ilike: Case insensitive like operator + * $and: Logical AND operator + * $or: Logical OR operator + + Example: + + .. code-block:: python + + vectorstore.similarity_search('kitty', k=10, filter={ + 'id': {'$in': [1, 5, 2, 9]} + }) + #%% md + + If you provide a dict with multiple fields, but no operators, + the top level will be interpreted as a logical **AND** filter + + vectorstore.similarity_search('ducks', k=10, filter={ + 'id': {'$in': [1, 5, 2, 9]}, + 'location': {'$in': ["pond", "market"]} + }) + """ def __init__(