llama-index-vector-stores-postgres 0.7.0__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/PKG-INFO +1 -1
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/llama_index/vector_stores/postgres/base.py +27 -5
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/pyproject.toml +1 -1
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/.gitignore +0 -0
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/LICENSE +0 -0
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/README.md +0 -0
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/llama_index/py.typed +0 -0
- {llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/llama_index/vector_stores/postgres/__init__.py +0 -0
|
@@ -49,6 +49,8 @@ PGType = Literal[
|
|
|
49
49
|
"date",
|
|
50
50
|
"timestamp",
|
|
51
51
|
"uuid",
|
|
52
|
+
# Array type for GIN indexing
|
|
53
|
+
"text[]",
|
|
52
54
|
]
|
|
53
55
|
|
|
54
56
|
|
|
@@ -81,6 +83,7 @@ def get_data_model(
|
|
|
81
83
|
from pgvector.sqlalchemy import Vector
|
|
82
84
|
from sqlalchemy import Column, Computed
|
|
83
85
|
from sqlalchemy.dialects.postgresql import (
|
|
86
|
+
ARRAY,
|
|
84
87
|
BIGINT,
|
|
85
88
|
JSON,
|
|
86
89
|
JSONB,
|
|
@@ -105,6 +108,8 @@ def get_data_model(
|
|
|
105
108
|
"date": Date,
|
|
106
109
|
"timestamp": DateTime,
|
|
107
110
|
"uuid": UUID,
|
|
111
|
+
# Array type for GIN indexing
|
|
112
|
+
"text[]": ARRAY(String),
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
indexed_metadata_keys = indexed_metadata_keys or set()
|
|
@@ -131,15 +136,33 @@ def get_data_model(
|
|
|
131
136
|
else:
|
|
132
137
|
embedding_col = Column(Vector(embed_dim)) # type: ignore
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
# BTREE indices for scalar types (existing behavior)
|
|
140
|
+
btree_indices = [
|
|
135
141
|
Index(
|
|
136
142
|
f"{indexname}_{key}_{pg_type.replace(' ', '_')}",
|
|
137
143
|
cast(column("metadata_").op("->>")(key), pg_type_map[pg_type]),
|
|
138
144
|
postgresql_using="btree",
|
|
139
145
|
)
|
|
140
146
|
for key, pg_type in indexed_metadata_keys
|
|
147
|
+
if pg_type != "text[]"
|
|
141
148
|
]
|
|
142
149
|
|
|
150
|
+
# GIN indices for text arrays (enables fast array operations with ?|, ?&, @> operators)
|
|
151
|
+
gin_indices = [
|
|
152
|
+
Index(
|
|
153
|
+
f"{indexname}_{key}_gin",
|
|
154
|
+
cast(
|
|
155
|
+
column("metadata_").op("->")(key), JSONB
|
|
156
|
+
), # Cast to JSONB for GIN index compatibility
|
|
157
|
+
postgresql_using="gin",
|
|
158
|
+
)
|
|
159
|
+
for key, pg_type in indexed_metadata_keys
|
|
160
|
+
if pg_type == "text[]"
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
# Combine both types of indices
|
|
164
|
+
metadata_indices = btree_indices + gin_indices
|
|
165
|
+
|
|
143
166
|
if hybrid_search:
|
|
144
167
|
|
|
145
168
|
class HybridAbstractData(base): # type: ignore
|
|
@@ -373,7 +396,6 @@ class PGVectorStore(BasePydanticVectorStore):
|
|
|
373
396
|
if not self._is_initialized:
|
|
374
397
|
return
|
|
375
398
|
|
|
376
|
-
self._session.close_all()
|
|
377
399
|
if self._engine:
|
|
378
400
|
self._engine.dispose()
|
|
379
401
|
if self._async_engine:
|
|
@@ -677,9 +699,9 @@ class PGVectorStore(BasePydanticVectorStore):
|
|
|
677
699
|
f"({filter_value})"
|
|
678
700
|
)
|
|
679
701
|
elif filter_.operator in [FilterOperator.ANY, FilterOperator.ALL]:
|
|
680
|
-
# Expects a
|
|
681
|
-
|
|
682
|
-
#
|
|
702
|
+
# Expects a text array stored in the metadata, and a list of values to compare
|
|
703
|
+
# Works with text[] arrays using PostgreSQL ?| (ANY) and ?& (ALL) operators
|
|
704
|
+
# Example: metadata_::jsonb->'tags' ?| array['AI', 'ML']
|
|
683
705
|
filter_value = ", ".join(f"'{e}'" for e in filter_.value)
|
|
684
706
|
|
|
685
707
|
return text(
|
{llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/pyproject.toml
RENAMED
|
@@ -27,7 +27,7 @@ dev = [
|
|
|
27
27
|
|
|
28
28
|
[project]
|
|
29
29
|
name = "llama-index-vector-stores-postgres"
|
|
30
|
-
version = "0.7.
|
|
30
|
+
version = "0.7.2"
|
|
31
31
|
description = "llama-index vector_stores postgres integration"
|
|
32
32
|
authors = [{name = "Your Name", email = "you@example.com"}]
|
|
33
33
|
requires-python = ">=3.9,<4.0"
|
{llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/.gitignore
RENAMED
|
File without changes
|
{llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/LICENSE
RENAMED
|
File without changes
|
{llama_index_vector_stores_postgres-0.7.0 → llama_index_vector_stores_postgres-0.7.2}/README.md
RENAMED
|
File without changes
|
|
File without changes
|