pgvector-haystack 1.2.0__tar.gz → 1.2.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-1.2.0 → pgvector_haystack-1.2.1}/CHANGELOG.md +7 -0
  2. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/PKG-INFO +5 -4
  3. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/README.md +1 -1
  4. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/document_stores/pgvector/document_store.py +3 -1
  5. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/test_document_store.py +45 -0
  6. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/.gitignore +0 -0
  7. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/LICENSE.txt +0 -0
  8. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/examples/embedding_retrieval.py +0 -0
  9. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/examples/hybrid_retrieval.py +0 -0
  10. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/pydoc/config.yml +0 -0
  11. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/pyproject.toml +0 -0
  12. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/components/retrievers/pgvector/__init__.py +0 -0
  13. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/components/retrievers/pgvector/embedding_retriever.py +0 -0
  14. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/components/retrievers/pgvector/keyword_retriever.py +0 -0
  15. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/document_stores/pgvector/__init__.py +0 -0
  16. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/src/haystack_integrations/document_stores/pgvector/filters.py +0 -0
  17. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/__init__.py +0 -0
  18. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/conftest.py +0 -0
  19. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/test_embedding_retrieval.py +0 -0
  20. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/test_filters.py +0 -0
  21. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/test_keyword_retrieval.py +0 -0
  22. {pgvector_haystack-1.2.0 → pgvector_haystack-1.2.1}/tests/test_retrievers.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/pgvector-v1.2.0] - 2024-11-22
4
+
5
+ ### 🚀 Features
6
+
7
+ - Add `create_extension` parameter to control vector extension creation (#1213)
8
+
9
+
3
10
  ## [integrations/pgvector-v1.1.0] - 2024-11-21
4
11
 
5
12
  ### 🚀 Features
@@ -1,12 +1,13 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pgvector-haystack
3
- Version: 1.2.0
3
+ Version: 1.2.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
7
7
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
8
8
  Author-email: deepset GmbH <info@deepset.ai>
9
- License: Apache-2.0
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE.txt
10
11
  Classifier: Development Status :: 4 - Beta
11
12
  Classifier: License :: OSI Approved :: Apache Software License
12
13
  Classifier: Programming Language :: Python
@@ -47,7 +48,7 @@ pip install pgvector-haystack
47
48
 
48
49
  Ensure that you have a PostgreSQL running with the `pgvector` extension. For a quick setup using Docker, run:
49
50
  ```
50
- docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres ankane/pgvector
51
+ docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres pgvector/pgvector:pg17
51
52
  ```
52
53
 
53
54
  then run the tests:
@@ -22,7 +22,7 @@ pip install pgvector-haystack
22
22
 
23
23
  Ensure that you have a PostgreSQL running with the `pgvector` extension. For a quick setup using Docker, run:
24
24
  ```
25
- docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres ankane/pgvector
25
+ docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres pgvector/pgvector:pg17
26
26
  ```
27
27
 
28
28
  then run the tests:
@@ -389,7 +389,9 @@ class PgvectorDocumentStore:
389
389
  )
390
390
  return
391
391
 
392
- sql_drop_index = SQL("DROP INDEX IF EXISTS {index_name}").format(index_name=Identifier(self.hnsw_index_name))
392
+ sql_drop_index = SQL("DROP INDEX IF EXISTS {schema_name}.{index_name}").format(
393
+ schema_name=Identifier(self.schema_name), index_name=Identifier(self.hnsw_index_name)
394
+ )
393
395
  self._execute_sql(sql_drop_index, error_msg="Could not drop HNSW index")
394
396
 
395
397
  self._create_hnsw_index()
@@ -5,6 +5,7 @@
5
5
  from unittest.mock import patch
6
6
 
7
7
  import numpy as np
8
+ import psycopg
8
9
  import pytest
9
10
  from haystack.dataclasses.document import ByteStream, Document
10
11
  from haystack.document_stores.errors import DuplicateDocumentError
@@ -259,3 +260,47 @@ def test_from_pg_to_haystack_documents():
259
260
  assert haystack_docs[2].meta == {"meta_key": "meta_value"}
260
261
  assert haystack_docs[2].embedding == [0.7, 0.8, 0.9]
261
262
  assert haystack_docs[2].score is None
263
+
264
+
265
+ @pytest.mark.integration
266
+ def test_hnsw_index_recreation():
267
+ def get_index_oid(document_store, schema_name, index_name):
268
+ sql_get_index_oid = """
269
+ SELECT c.oid
270
+ FROM pg_class c
271
+ JOIN pg_namespace n ON n.oid = c.relnamespace
272
+ WHERE c.relkind = 'i'
273
+ AND n.nspname = %s
274
+ AND c.relname = %s;
275
+ """
276
+ return document_store.cursor.execute(sql_get_index_oid, (schema_name, index_name)).fetchone()[0]
277
+
278
+ # create a new schema
279
+ connection_string = "postgresql://postgres:postgres@localhost:5432/postgres"
280
+ schema_name = "test_schema"
281
+ with psycopg.connect(connection_string, autocommit=True) as conn:
282
+ conn.execute(f"CREATE SCHEMA IF NOT EXISTS {schema_name}")
283
+
284
+ # create a first document store and trigger the creation of the hnsw index
285
+ params = {
286
+ "connection_string": Secret.from_token(connection_string),
287
+ "schema_name": schema_name,
288
+ "table_name": "haystack_test_hnsw_index_recreation",
289
+ "search_strategy": "hnsw",
290
+ }
291
+ ds1 = PgvectorDocumentStore(**params)
292
+ ds1._initialize_table()
293
+
294
+ # get the hnsw index oid
295
+ hnws_index_name = "haystack_hnsw_index"
296
+ first_oid = get_index_oid(ds1, ds1.schema_name, hnws_index_name)
297
+
298
+ # create second document store with recreation enabled
299
+ ds2 = PgvectorDocumentStore(**params, hnsw_recreate_index_if_exists=True)
300
+ ds2._initialize_table()
301
+
302
+ # get the index oid
303
+ second_oid = get_index_oid(ds2, ds2.schema_name, hnws_index_name)
304
+
305
+ # verify that oids differ
306
+ assert second_oid != first_oid, "Index was not recreated (OID remained the same)"