mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
AsyncPGVectorStore.as_retriever filter in search_kwargs is not translated to target langchain_metadata column #101
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cs051045 on GitHub (Feb 11, 2026).
Hi,
I’m trying to understand how metadata filtering is intended to work when using AsyncPGVectorStore via as_retriever(), and I may be missing something.
I’m passing a filter through search_kwargs, for example:
Based on the documentation, I expected this filter to be applied to the configured metadata JSON column.
What I’m observing
Tracing the async execution path shows that the filter is eventually processed by:
At this point, the filter field (some_metadata_key) is treated as a direct SQL column name, not as a key inside the metadata JSON column.
From reading the implementation, the generated SQL always follows patterns like:
There doesn’t appear to be any transformation such as:
langchain_metadata->> 'some_metadata_key'
or any logic that checks whether a filter should target the metadata JSON column instead of a physical table column.
As a result I get this error:
Is this behavior intentional (filters are only meant to apply to actual table columns)?
I don’t see where such a transformation would occur in:
_create_filter_clause
_handle_field_filter