pgvector-haystack 3.0.0__tar.gz → 3.0.1__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.
Files changed (22) hide show
  1. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/CHANGELOG.md +135 -127
  2. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/PKG-INFO +1 -1
  3. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/document_stores/pgvector/document_store.py +15 -6
  4. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/test_document_store.py +47 -0
  5. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/.gitignore +0 -0
  6. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/LICENSE.txt +0 -0
  7. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/README.md +0 -0
  8. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/examples/embedding_retrieval.py +0 -0
  9. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/examples/hybrid_retrieval.py +0 -0
  10. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/pydoc/config.yml +0 -0
  11. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/pyproject.toml +0 -0
  12. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/components/retrievers/pgvector/__init__.py +0 -0
  13. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/components/retrievers/pgvector/embedding_retriever.py +0 -0
  14. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/components/retrievers/pgvector/keyword_retriever.py +0 -0
  15. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/document_stores/pgvector/__init__.py +0 -0
  16. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/src/haystack_integrations/document_stores/pgvector/filters.py +0 -0
  17. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/__init__.py +0 -0
  18. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/conftest.py +0 -0
  19. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/test_embedding_retrieval.py +0 -0
  20. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/test_filters.py +0 -0
  21. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/test_keyword_retrieval.py +0 -0
  22. {pgvector_haystack-3.0.0 → pgvector_haystack-3.0.1}/tests/test_retrievers.py +0 -0
@@ -1,127 +1,135 @@
1
- # Changelog
2
-
3
- ## [integrations/pgvector-v2.0.0] - 2025-02-13
4
-
5
- ### 🧹 Chores
6
-
7
- - Pgvector - remove support for dataframe (#1370)
8
-
9
- ## [integrations/pgvector-v1.3.0] - 2025-02-03
10
-
11
- ### 🚀 Features
12
-
13
- - Pgvector - add like and not like filters (#1341)
14
-
15
- ### 🧹 Chores
16
-
17
- - Inherit from `FilterDocumentsTestWithDataframe` in Document Stores (#1290)
18
-
19
-
20
- ## [integrations/pgvector-v1.2.1] - 2025-01-10
21
-
22
- ### 🐛 Bug Fixes
23
-
24
- - PgvectorDocumentStore - use appropriate schema name if dropping index (#1277)
25
-
26
-
27
- ## [integrations/pgvector-v1.2.0] - 2024-11-22
28
-
29
- ### 🚀 Features
30
-
31
- - Add `create_extension` parameter to control vector extension creation (#1213)
32
-
33
-
34
- ## [integrations/pgvector-v1.1.0] - 2024-11-21
35
-
36
- ### 🚀 Features
37
-
38
- - Add filter_policy to pgvector integration (#820)
39
- - Add schema support to pgvector document store. (#1095)
40
- - Pgvector - recreate the connection if it is no longer valid (#1202)
41
-
42
- ### 🐛 Bug Fixes
43
-
44
- - `PgVector` - Fallback to default filter policy when deserializing retrievers without the init parameter (#900)
45
-
46
- ### 📚 Documentation
47
-
48
- - Explain different connection string formats in the docstring (#1132)
49
-
50
- ### 🧪 Testing
51
-
52
- - Do not retry tests in `hatch run test` command (#954)
53
-
54
- ### ⚙️ CI
55
-
56
- - Retry tests to reduce flakyness (#836)
57
- - Adopt uv as installer (#1142)
58
-
59
- ### 🧹 Chores
60
-
61
- - Update ruff invocation to include check parameter (#853)
62
- - PgVector - remove legacy filter support (#1068)
63
- - Update changelog after removing legacy filters (#1083)
64
- - Update ruff linting scripts and settings (#1105)
65
-
66
- ### 🌀 Miscellaneous
67
-
68
- - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
69
- - Chore: Minor retriever pydoc fix (#884)
70
- - Chore: Update pgvector test for the new `apply_filter_policy` usage (#970)
71
- - Chore: pgvector ruff update, don't ruff tests (#984)
72
-
73
- ## [integrations/pgvector-v0.4.0] - 2024-06-20
74
-
75
- ### 🚀 Features
76
-
77
- - Defer the database connection to when it's needed (#773)
78
- - Add customizable index names for pgvector (#818)
79
-
80
- ### 🌀 Miscellaneous
81
-
82
- - Docs: add missing api references (#728)
83
- - [deepset-ai/haystack-core-integrations#727] (#738)
84
-
85
- ## [integrations/pgvector-v0.2.0] - 2024-05-08
86
-
87
- ### 🚀 Features
88
-
89
- - `MongoDBAtlasEmbeddingRetriever` (#427)
90
- - Implement keyword retrieval for pgvector integration (#644)
91
-
92
- ### 🐛 Bug Fixes
93
-
94
- - Fix order of API docs (#447)
95
-
96
- ### 📚 Documentation
97
-
98
- - Update category slug (#442)
99
- - Disable-class-def (#556)
100
-
101
- ### 🌀 Miscellaneous
102
-
103
- - Pgvector - review docstrings and API reference (#502)
104
- - Refactor tests (#574)
105
- - Remove references to Python 3.7 (#601)
106
- - Make Document Stores initially skip `SparseEmbedding` (#606)
107
- - Chore: add license classifiers (#680)
108
- - Type hints in pgvector document store updated for 3.8 compability (#704)
109
- - Chore: change the pydoc renderer class (#718)
110
-
111
- ## [integrations/pgvector-v0.1.0] - 2024-02-14
112
-
113
- ### 🐛 Bug Fixes
114
-
115
- - Pgvector: fix linting (#328)
116
-
117
- ### 🌀 Miscellaneous
118
-
119
- - Pgvector Document Store - minimal implementation (#239)
120
- - Pgvector - filters (#257)
121
- - Pgvector - embedding retrieval (#298)
122
- - Pgvector - Embedding Retriever (#320)
123
- - Pgvector: generate API docs (#325)
124
- - Pgvector: add an example (#334)
125
- - Adopt `Secret` to pgvector (#402)
126
-
127
- <!-- generated by git-cliff -->
1
+ # Changelog
2
+
3
+ ## [integrations/pgvector-v3.0.0] - 2025-03-11
4
+
5
+ ### 🧹 Chores
6
+
7
+ - Remove Python 3.8 support (#1421)
8
+ - Use Haystack logging across integrations (#1484)
9
+ - Pgvector - pin haystack and remove dataframe checks (#1518)
10
+
11
+ ## [integrations/pgvector-v2.0.0] - 2025-02-13
12
+
13
+ ### 🧹 Chores
14
+
15
+ - Pgvector - remove support for dataframe (#1370)
16
+
17
+ ## [integrations/pgvector-v1.3.0] - 2025-02-03
18
+
19
+ ### 🚀 Features
20
+
21
+ - Pgvector - add like and not like filters (#1341)
22
+
23
+ ### 🧹 Chores
24
+
25
+ - Inherit from `FilterDocumentsTestWithDataframe` in Document Stores (#1290)
26
+
27
+
28
+ ## [integrations/pgvector-v1.2.1] - 2025-01-10
29
+
30
+ ### 🐛 Bug Fixes
31
+
32
+ - PgvectorDocumentStore - use appropriate schema name if dropping index (#1277)
33
+
34
+
35
+ ## [integrations/pgvector-v1.2.0] - 2024-11-22
36
+
37
+ ### 🚀 Features
38
+
39
+ - Add `create_extension` parameter to control vector extension creation (#1213)
40
+
41
+
42
+ ## [integrations/pgvector-v1.1.0] - 2024-11-21
43
+
44
+ ### 🚀 Features
45
+
46
+ - Add filter_policy to pgvector integration (#820)
47
+ - Add schema support to pgvector document store. (#1095)
48
+ - Pgvector - recreate the connection if it is no longer valid (#1202)
49
+
50
+ ### 🐛 Bug Fixes
51
+
52
+ - `PgVector` - Fallback to default filter policy when deserializing retrievers without the init parameter (#900)
53
+
54
+ ### 📚 Documentation
55
+
56
+ - Explain different connection string formats in the docstring (#1132)
57
+
58
+ ### 🧪 Testing
59
+
60
+ - Do not retry tests in `hatch run test` command (#954)
61
+
62
+ ### ⚙️ CI
63
+
64
+ - Retry tests to reduce flakyness (#836)
65
+ - Adopt uv as installer (#1142)
66
+
67
+ ### 🧹 Chores
68
+
69
+ - Update ruff invocation to include check parameter (#853)
70
+ - PgVector - remove legacy filter support (#1068)
71
+ - Update changelog after removing legacy filters (#1083)
72
+ - Update ruff linting scripts and settings (#1105)
73
+
74
+ ### 🌀 Miscellaneous
75
+
76
+ - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
77
+ - Chore: Minor retriever pydoc fix (#884)
78
+ - Chore: Update pgvector test for the new `apply_filter_policy` usage (#970)
79
+ - Chore: pgvector ruff update, don't ruff tests (#984)
80
+
81
+ ## [integrations/pgvector-v0.4.0] - 2024-06-20
82
+
83
+ ### 🚀 Features
84
+
85
+ - Defer the database connection to when it's needed (#773)
86
+ - Add customizable index names for pgvector (#818)
87
+
88
+ ### 🌀 Miscellaneous
89
+
90
+ - Docs: add missing api references (#728)
91
+ - [deepset-ai/haystack-core-integrations#727] (#738)
92
+
93
+ ## [integrations/pgvector-v0.2.0] - 2024-05-08
94
+
95
+ ### 🚀 Features
96
+
97
+ - `MongoDBAtlasEmbeddingRetriever` (#427)
98
+ - Implement keyword retrieval for pgvector integration (#644)
99
+
100
+ ### 🐛 Bug Fixes
101
+
102
+ - Fix order of API docs (#447)
103
+
104
+ ### 📚 Documentation
105
+
106
+ - Update category slug (#442)
107
+ - Disable-class-def (#556)
108
+
109
+ ### 🌀 Miscellaneous
110
+
111
+ - Pgvector - review docstrings and API reference (#502)
112
+ - Refactor tests (#574)
113
+ - Remove references to Python 3.7 (#601)
114
+ - Make Document Stores initially skip `SparseEmbedding` (#606)
115
+ - Chore: add license classifiers (#680)
116
+ - Type hints in pgvector document store updated for 3.8 compability (#704)
117
+ - Chore: change the pydoc renderer class (#718)
118
+
119
+ ## [integrations/pgvector-v0.1.0] - 2024-02-14
120
+
121
+ ### 🐛 Bug Fixes
122
+
123
+ - Pgvector: fix linting (#328)
124
+
125
+ ### 🌀 Miscellaneous
126
+
127
+ - Pgvector Document Store - minimal implementation (#239)
128
+ - Pgvector - filters (#257)
129
+ - Pgvector - embedding retrieval (#298)
130
+ - Pgvector - Embedding Retriever (#320)
131
+ - Pgvector: generate API docs (#325)
132
+ - Pgvector: add an example (#334)
133
+ - Adopt `Secret` to pgvector (#402)
134
+
135
+ <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pgvector-haystack
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: An integration of pgvector (vector search extension for Postgres) with Haystack
5
5
  Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
6
6
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/pgvector/README.md
@@ -23,7 +23,7 @@ from .filters import _convert_filters_to_where_clause_and_params
23
23
  logger = logging.getLogger(__name__)
24
24
 
25
25
  CREATE_TABLE_STATEMENT = """
26
- CREATE TABLE IF NOT EXISTS {schema_name}.{table_name} (
26
+ CREATE TABLE {schema_name}.{table_name} (
27
27
  id VARCHAR(128) PRIMARY KEY,
28
28
  embedding VECTOR({embedding_dimension}),
29
29
  content TEXT,
@@ -310,13 +310,22 @@ class PgvectorDocumentStore:
310
310
  Creates the table to store Haystack documents if it doesn't exist yet.
311
311
  """
312
312
 
313
- create_sql = SQL(CREATE_TABLE_STATEMENT).format(
314
- schema_name=Identifier(self.schema_name),
315
- table_name=Identifier(self.table_name),
316
- embedding_dimension=SQLLiteral(self.embedding_dimension),
313
+ table_exists = bool(
314
+ self._execute_sql(
315
+ "SELECT 1 FROM pg_tables WHERE schemaname = %s AND tablename = %s",
316
+ (self.schema_name, self.table_name),
317
+ "Could not check if table exists",
318
+ ).fetchone()
317
319
  )
318
320
 
319
- self._execute_sql(create_sql, error_msg="Could not create table in PgvectorDocumentStore")
321
+ if not table_exists:
322
+ create_sql = SQL(CREATE_TABLE_STATEMENT).format(
323
+ schema_name=Identifier(self.schema_name),
324
+ table_name=Identifier(self.table_name),
325
+ embedding_dimension=SQLLiteral(self.embedding_dimension),
326
+ )
327
+
328
+ self._execute_sql(create_sql, error_msg="Could not create table in PgvectorDocumentStore")
320
329
 
321
330
  def delete_table(self):
322
331
  """
@@ -288,3 +288,50 @@ def test_hnsw_index_recreation():
288
288
 
289
289
  # verify that oids differ
290
290
  assert second_oid != first_oid, "Index was not recreated (OID remained the same)"
291
+
292
+ # Clean up: drop the schema after the test
293
+ with psycopg.connect(connection_string, autocommit=True) as conn:
294
+ conn.execute(f"DROP SCHEMA IF EXISTS {schema_name} CASCADE")
295
+
296
+
297
+ @pytest.mark.integration
298
+ def test_create_table_if_not_exists():
299
+ def get_table_oid(document_store, schema_name, table_name):
300
+ sql_get_table_oid = """
301
+ SELECT c.oid
302
+ FROM pg_class c
303
+ JOIN pg_namespace n ON n.oid = c.relnamespace
304
+ WHERE c.relkind = 'r'
305
+ AND n.nspname = %s
306
+ AND c.relname = %s;
307
+ """
308
+ return document_store.cursor.execute(sql_get_table_oid, (schema_name, table_name)).fetchone()[0]
309
+
310
+ connection_string = "postgresql://postgres:postgres@localhost:5432/postgres"
311
+ schema_name = "test_schema"
312
+ table_name = "test_table"
313
+
314
+ # Create a new schema
315
+ with psycopg.connect(connection_string, autocommit=True) as conn:
316
+ conn.execute(f"CREATE SCHEMA {schema_name}")
317
+
318
+ document_store = PgvectorDocumentStore(
319
+ connection_string=Secret.from_token(connection_string),
320
+ schema_name=schema_name,
321
+ table_name=table_name,
322
+ )
323
+
324
+ document_store._create_table_if_not_exists()
325
+
326
+ first_table_oid = get_table_oid(document_store, schema_name, table_name)
327
+ assert first_table_oid is not None, "Table was not created"
328
+
329
+ document_store._create_table_if_not_exists()
330
+
331
+ second_table_oid = get_table_oid(document_store, schema_name, table_name)
332
+
333
+ assert first_table_oid == second_table_oid, "Table was recreated"
334
+
335
+ # Clean up: drop the schema after the test
336
+ with psycopg.connect(connection_string, autocommit=True) as conn:
337
+ conn.execute(f"DROP SCHEMA IF EXISTS {schema_name} CASCADE")