You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add GIN index support for text array metadata in PostgreSQL vector store
Fixes#20128
Enable automatic GIN index creation for text array metadata fields in the PostgreSQL vector store. This allows fast array membership queries using PostgreSQL operators (?|, ?&, @>) without requiring raw SQL workarounds.
Changes:
- Extended PGType to support text[] array type
- Modified get_data_model() to create GIN indices for array fields and BTREE indices for scalar fields
- Cast metadata to JSONB in GIN index creation for compatibility with both JSON and JSONB columns
- Added comprehensive tests covering GIN index creation, CONTAINS, ANY, ALL operators, and mixed BTREE/GIN queries
- Tests use PostgreSQL system catalogs (pg_class, pg_am) for type-safe index verification
This maintains backward compatibility - existing BTREE indices continue working, and GIN indices are only created when text[] is specified in indexed_metadata_keys.
Copy file name to clipboardExpand all lines: llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py
0 commit comments