diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py index 01a166c265e416339a2f0f11713287a83060095f..3408ed9234a4d5b0f932d01064e83d948d0bb44d 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py @@ -359,10 +359,12 @@ class PGVectorStore(BasePydanticVectorStore): from sqlalchemy import text if filter_.operator in [FilterOperator.IN, FilterOperator.NIN]: + # Expects a single value in the metadata, and a list to compare return text( f"metadata_->>'{filter_.key}' {self._to_postgres_operator(filter_.operator)} :values" ).bindparams(values=tuple(filter_.value)) elif filter_.operator == FilterOperator.CONTAINS: + # Expects a list stored in the metadata, and a single value to compare return text( f"metadata_::jsonb->'{filter_.key}' " f"{self._to_postgres_operator(filter_.operator)} "