faiss-haystack 2.1.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.
@@ -0,0 +1,69 @@
1
+ # Changelog
2
+
3
+ ## [integrations/faiss-v3.0.0] - 2026-10-16
4
+
5
+ ### 🧪 Testing
6
+
7
+ - Use Python 3.11 in tests instead of 3.10 (#4103)
8
+ - Test compatible integrations with Python 3.15; update pyproject (#4104)
9
+
10
+ ### ⚙️ CI
11
+
12
+ - Improve changelog generation; fix existing changelogs (#3883)
13
+
14
+ ### 🧹 Chores
15
+
16
+ - Switch remaining document stores to haystack.logging (#4011)
17
+ - [**breaking**] Drop Python 3.10 support (#4105)
18
+
19
+
20
+ ## [integrations/faiss-v2.1.0] - 2026-09-01
21
+
22
+ ### 🐛 Bug Fixes
23
+
24
+ - Fix new issues raised by ruff 0.16.0 (#3670)
25
+ - `FAISSDocumentStore` with `search_term`, pagination and returning `(values, total_count)` (#3682)
26
+ - `FAISSDocumentStore` get_metadata_field_unique_values setting list of values to return to `Any` (#3704)
27
+ - `FAISSDocumentStore` adding filter to unique metadata values (#3753)
28
+ - Standardize license files (#3771)
29
+
30
+ ### 📚 Documentation
31
+
32
+ - Replace old haystack core imports with haystack_integrations paths (#3545)
33
+
34
+ ### 🧪 Testing
35
+
36
+ - Track test coverage for all integrations (#3065)
37
+ - Mark some tests as integration in Faiss and Qdrant (#3076)
38
+ - Faiss - add unit tests (#3213)
39
+ - `FAISSDocumentStore` removing duplicated tests already covered by haystack Mixin tests (#3778)
40
+
41
+ ### 🧹 Chores
42
+
43
+ - Improve consistency of integrations folder structure (#3430)
44
+ - Re-standardize READMEs (#3768)
45
+
46
+
47
+ ## [integrations/faiss-v2.0.0] - 2026-03-23
48
+
49
+ ### 🧪 Testing
50
+
51
+ - Test compatible integrations with python 3.14; update pyproject (#3001)
52
+ - `FaissDocumentStore` use Mixin tests (#3024)
53
+
54
+ ### ⚙️ CI
55
+
56
+ - Adding FAISS github workflow (#2879)
57
+
58
+ ### 🧹 Chores
59
+
60
+ - FAISS - small changes to improve consistency with the codebase (#2890)
61
+ - Standardize author mentions (#2897)
62
+ - Add ANN type annotations to faiss, fastembed, firecrawl, github, google_ai (#2988)
63
+ - Enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in integrations 11-20 (#3009)
64
+
65
+ ### 🌀 Miscellaneous
66
+
67
+ - Add FAISS DocumentStore integration (#2844)
68
+
69
+ <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: faiss-haystack
3
- Version: 2.1.0
3
+ Version: 3.0.1
4
4
  Summary: An integration of FAISS (library for efficient similarity search of dense vectors) with Haystack
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/faiss#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -11,17 +11,17 @@ License-File: LICENSE.txt
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
18
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
19
  Classifier: Programming Language :: Python :: Implementation :: CPython
20
20
  Classifier: Programming Language :: Python :: Implementation :: PyPy
21
- Requires-Python: >=3.10
21
+ Requires-Python: >=3.11
22
22
  Requires-Dist: faiss-cpu>=1.8.0
23
23
  Requires-Dist: haystack-ai>=2.26.1
24
- Requires-Dist: numpy<2,>=1.22; python_version < '3.13'
24
+ Requires-Dist: numpy<2,>=1.23.2; python_version < '3.13'
25
25
  Description-Content-Type: text/markdown
26
26
 
27
27
  # faiss-haystack
@@ -7,7 +7,7 @@ name = "faiss-haystack"
7
7
  dynamic = ["version"]
8
8
  description = 'An integration of FAISS (library for efficient similarity search of dense vectors) with Haystack'
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "Apache-2.0"
12
12
  keywords = []
13
13
  authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
@@ -15,18 +15,18 @@ classifiers = [
15
15
  "License :: OSI Approved :: Apache Software License",
16
16
  "Development Status :: 4 - Beta",
17
17
  "Programming Language :: Python",
18
- "Programming Language :: Python :: 3.10",
19
18
  "Programming Language :: Python :: 3.11",
20
19
  "Programming Language :: Python :: 3.12",
21
20
  "Programming Language :: Python :: 3.13",
22
21
  "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
23
23
  "Programming Language :: Python :: Implementation :: CPython",
24
24
  "Programming Language :: Python :: Implementation :: PyPy",
25
25
  ]
26
26
  dependencies = [
27
27
  "haystack-ai>=2.26.1",
28
28
  "faiss-cpu>=1.8.0",
29
- "numpy>=1.22,<2; python_version < '3.13'",
29
+ "numpy>=1.23.2,<2; python_version < '3.13'",
30
30
  ]
31
31
 
32
32
  [project.urls]
@@ -3,14 +3,13 @@
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
5
  import json
6
- import logging
7
6
  from collections.abc import Iterable
8
7
  from dataclasses import replace
9
8
  from pathlib import Path
10
9
  from typing import Any
11
10
 
12
11
  import numpy as np
13
- from haystack import default_from_dict, default_to_dict
12
+ from haystack import default_from_dict, default_to_dict, logging
14
13
  from haystack.dataclasses import Document
15
14
  from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError
16
15
  from haystack.document_stores.types import DuplicatePolicy
@@ -153,9 +152,9 @@ class FAISSDocumentStore:
153
152
  msg = f"Document with id '{doc.id}' already exists."
154
153
  raise DuplicateDocumentError(msg)
155
154
 
156
- # Process documents
157
- ids_to_add_to_index = []
158
- vectors_to_add = []
155
+ # Process documents. Pending vectors are keyed by document ID so that a later duplicate in the same
156
+ # batch replaces the earlier one instead of leaving an orphaned vector in the FAISS index.
157
+ pending_vectors: dict[str, tuple[int, list[float]]] = {}
159
158
 
160
159
  docs_written = 0
161
160
 
@@ -169,6 +168,7 @@ class FAISSDocumentStore:
169
168
  # FAISS doesn't support easy update. We'd have to remove and add.
170
169
  # For MVP, let's implement remove then add for overwrite.
171
170
  self.delete_documents([doc.id])
171
+ pending_vectors.pop(doc.id, None)
172
172
 
173
173
  self.documents[doc.id] = doc
174
174
 
@@ -180,15 +180,14 @@ class FAISSDocumentStore:
180
180
  self.id_map[int_id] = doc.id
181
181
  self.inverse_id_map[doc.id] = int_id
182
182
 
183
- ids_to_add_to_index.append(int_id)
184
- vectors_to_add.append(doc.embedding)
183
+ pending_vectors[doc.id] = (int_id, doc.embedding)
185
184
 
186
185
  docs_written += 1
187
186
 
188
187
  # Add to FAISS
189
- if vectors_to_add:
190
- vectors = np.array(vectors_to_add, dtype="float32")
191
- ids = np.array(ids_to_add_to_index, dtype="int64")
188
+ if pending_vectors:
189
+ vectors = np.array([vector for _, vector in pending_vectors.values()], dtype="float32")
190
+ ids = np.array([int_id for int_id, _ in pending_vectors.values()], dtype="int64")
192
191
  index = self._get_index_or_raise()
193
192
  index.add_with_ids(vectors, ids)
194
193
 
@@ -599,7 +598,7 @@ class FAISSDocumentStore:
599
598
  # Verify sync
600
599
  if len(self.documents) != len(self.id_map):
601
600
  logger.warning(
602
- "Loaded %d documents but %d ID mappings. Index might be out of sync.",
603
- len(self.documents),
604
- len(self.id_map),
601
+ "Loaded {documents_count} documents but {mappings_count} ID mappings. Index might be out of sync.",
602
+ documents_count=len(self.documents),
603
+ mappings_count=len(self.id_map),
605
604
  )
@@ -55,6 +55,21 @@ class TestFAISSDocumentStoreUnit:
55
55
  with pytest.raises(DuplicateDocumentError, match="already exists"):
56
56
  ds.write_documents([Document(id="dup", content="second")], policy=DuplicatePolicy.FAIL)
57
57
 
58
+ def test_write_documents_overwrite_duplicate_in_same_batch_leaves_no_orphan_vector(self):
59
+ ds = FAISSDocumentStore(embedding_dim=2)
60
+ docs = [
61
+ Document(id="a", content="old", embedding=[0.0, 0.0]),
62
+ Document(id="a", content="new", embedding=[0.1, 0.1]),
63
+ Document(id="b", content="b", embedding=[5.0, 5.0]),
64
+ ]
65
+ ds.write_documents(docs, policy=DuplicatePolicy.OVERWRITE)
66
+
67
+ assert ds.count_documents() == 2
68
+ assert ds.index.ntotal == 2
69
+ results = ds.search([0.0, 0.0], top_k=2)
70
+ assert [doc.id for doc in results] == ["a", "b"]
71
+ assert results[0].content == "new"
72
+
58
73
  @pytest.mark.parametrize(
59
74
  ("filters", "error_match"),
60
75
  [
@@ -1,25 +0,0 @@
1
- # Changelog
2
-
3
- ## [integrations/faiss-v2.0.0] - 2026-03-23
4
-
5
- ### 🧪 Testing
6
-
7
- - Test compatible integrations with python 3.14; update pyproject (#3001)
8
- - `FaissDocumentStore` use Mixin tests (#3024)
9
-
10
- ### ⚙️ CI
11
-
12
- - Adding FAISS github workflow (#2879)
13
-
14
- ### 🧹 Chores
15
-
16
- - FAISS - small changes to improve consistency with the codebase (#2890)
17
- - Standardize author mentions (#2897)
18
- - Add ANN type annotations to faiss, fastembed, firecrawl, github, google_ai (#2988)
19
- - Enforce ruff docstring rules (D102/D103/D205/D209/D213/D417/D419) in integrations 11-20 (#3009)
20
-
21
- ### 🌀 Miscellaneous
22
-
23
- - Add FAISS DocumentStore integration (#2844)
24
-
25
- <!-- generated by git-cliff -->
File without changes