chroma-haystack 4.4.0__tar.gz → 5.0.0__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.
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/CHANGELOG.md +57 -11
- chroma_haystack-4.4.0/LICENSE → chroma_haystack-5.0.0/LICENSE.txt +1 -1
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/PKG-INFO +6 -7
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/README.md +2 -2
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/pyproject.toml +2 -2
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/chroma/document_store.py +31 -14
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/test_document_store.py +0 -102
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/test_document_store_async.py +1 -45
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/.gitignore +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_01.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_02.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_03.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_04.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_05.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_06.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_07.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_08.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_09.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_10.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_11.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_12.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_20.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_21.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_22.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_23.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_24.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_25.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_26.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_27.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_28.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_29.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_30.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_31.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_32.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_40.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_41.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_42.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_43.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_44.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_45.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_46.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_50.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_51.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_52.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/data/usr_90.txt +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/example/example.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/pydoc/config_docusaurus.yml +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/components/retrievers/chroma/__init__.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/components/retrievers/chroma/retriever.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/chroma/__init__.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/chroma/errors.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/chroma/filters.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/chroma/utils.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/__init__.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/conftest.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/test_filters.py +0 -0
- {chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/tests/test_retriever.py +0 -0
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/chroma-v4.5.0] - 2026-09-01
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- Fix new issues raised by ruff 0.16.0 (#3670)
|
|
8
|
+
- `ChromDocumentStore` get_metadata_field_unique_values setting list of values to return to `Any` (#3707)
|
|
9
|
+
- Chroma adding optional parameter `filters` to `get_metadata_field_unique_values()` (#3742)
|
|
10
|
+
- Standardize license files (#3771)
|
|
11
|
+
- `ChromaDocumentStore` removing duplicated tests already covered by haystack Mixin tests + fixing dedup values (#3777)
|
|
12
|
+
|
|
13
|
+
### 🧹 Chores
|
|
14
|
+
|
|
15
|
+
- Re-standardize READMEs (#3768)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [integrations/chroma-v4.4.0] - 2026-07-24
|
|
19
|
+
|
|
20
|
+
### 🚀 Features
|
|
21
|
+
|
|
22
|
+
- Chroma - add sync closing methods (#3660)
|
|
23
|
+
|
|
24
|
+
### 🐛 Bug Fixes
|
|
25
|
+
|
|
26
|
+
- `ChromaDocumentStore` match `search_term` against metadata field value, not content (#3644)
|
|
27
|
+
|
|
28
|
+
|
|
3
29
|
## [integrations/chroma-v4.3.2] - 2026-07-17
|
|
4
30
|
|
|
5
31
|
### 🐛 Bug Fixes
|
|
@@ -98,10 +124,6 @@
|
|
|
98
124
|
- Adding `delete_by_filter()` and `update_by_filter()` to `ChromaDocumentStore` (#2649)
|
|
99
125
|
|
|
100
126
|
|
|
101
|
-
### ⚙️ CI
|
|
102
|
-
|
|
103
|
-
- Change pytest command (#2475)
|
|
104
|
-
|
|
105
127
|
### 🧹 Chores
|
|
106
128
|
|
|
107
129
|
- Remove Readme API CI workflow and configs (#2573)
|
|
@@ -110,6 +132,13 @@
|
|
|
110
132
|
|
|
111
133
|
- Adopt PEP 585 type hinting (part 1) (#2509)
|
|
112
134
|
|
|
135
|
+
## [integrations/chroma-v3.4.1] - 2025-11-11
|
|
136
|
+
|
|
137
|
+
### ⚙️ CI
|
|
138
|
+
|
|
139
|
+
- Change pytest command (#2475)
|
|
140
|
+
|
|
141
|
+
|
|
113
142
|
## [integrations/chroma-v3.4.0] - 2025-10-27
|
|
114
143
|
|
|
115
144
|
### 🚀 Features
|
|
@@ -149,6 +178,8 @@
|
|
|
149
178
|
|
|
150
179
|
- Align core-integrations Hatch scripts (#1898)
|
|
151
180
|
|
|
181
|
+
## [integrations/chroma-v3.1.0] - 2025-04-14
|
|
182
|
+
|
|
152
183
|
|
|
153
184
|
## [integrations/chroma-v2.0.3] - 2025-04-04
|
|
154
185
|
|
|
@@ -268,15 +299,29 @@
|
|
|
268
299
|
|
|
269
300
|
## [integrations/chroma-v0.20.1] - 2024-07-15
|
|
270
301
|
|
|
302
|
+
### 🐛 Bug Fixes
|
|
303
|
+
|
|
304
|
+
- `Chroma` - Fallback to default filter policy when deserializing retrievers without the init parameter (#897)
|
|
305
|
+
|
|
306
|
+
## [integrations/chroma-v0.20.0] - 2024-07-15
|
|
307
|
+
|
|
271
308
|
### 🚀 Features
|
|
272
309
|
|
|
273
|
-
- Added distance_function property to ChromadocumentStore (#817)
|
|
274
310
|
- Add filter_policy to chroma integration (#826)
|
|
275
311
|
|
|
276
312
|
### 🐛 Bug Fixes
|
|
277
313
|
|
|
278
314
|
- Allow search in ChromaDocumentStore without metadata (#863)
|
|
279
|
-
|
|
315
|
+
|
|
316
|
+
### 🌀 Miscellaneous
|
|
317
|
+
|
|
318
|
+
- Chore: Minor retriever pydoc fix (#884)
|
|
319
|
+
|
|
320
|
+
## [integrations/chroma-v0.19.0] - 2024-07-01
|
|
321
|
+
|
|
322
|
+
### 🚀 Features
|
|
323
|
+
|
|
324
|
+
- Added distance_function property to ChromadocumentStore (#817)
|
|
280
325
|
|
|
281
326
|
### ⚙️ CI
|
|
282
327
|
|
|
@@ -289,7 +334,6 @@
|
|
|
289
334
|
### 🌀 Miscellaneous
|
|
290
335
|
|
|
291
336
|
- Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
|
|
292
|
-
- Chore: Minor retriever pydoc fix (#884)
|
|
293
337
|
|
|
294
338
|
## [integrations/chroma-v0.18.0] - 2024-05-31
|
|
295
339
|
|
|
@@ -363,15 +407,17 @@
|
|
|
363
407
|
|
|
364
408
|
## [integrations/chroma-v0.11.0] - 2024-01-18
|
|
365
409
|
|
|
366
|
-
### 🐛 Bug Fixes
|
|
367
|
-
|
|
368
|
-
- Chroma DocumentStore creation for pre-existing collection name (#157)
|
|
369
|
-
|
|
370
410
|
### 🌀 Miscellaneous
|
|
371
411
|
|
|
372
412
|
- Mount chroma integration under `haystack_integrations.*` (#193)
|
|
373
413
|
- Remove ChromaSingleQueryRetriever (#240)
|
|
374
414
|
|
|
415
|
+
## [integrations/chroma-v0.10.0] - 2024-01-17
|
|
416
|
+
|
|
417
|
+
### 🐛 Bug Fixes
|
|
418
|
+
|
|
419
|
+
- Chroma DocumentStore creation for pre-existing collection name (#157)
|
|
420
|
+
|
|
375
421
|
## [integrations/chroma-v0.9.0] - 2023-12-20
|
|
376
422
|
|
|
377
423
|
### 🐛 Bug Fixes
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2023 deepset GmbH
|
|
189
|
+
Copyright 2023-present deepset GmbH
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: chroma-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0.0
|
|
4
4
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/chroma#readme
|
|
5
5
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
6
6
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/chroma
|
|
7
7
|
Author-email: deepset GmbH <info@deepset.ai>
|
|
8
8
|
License-Expression: Apache-2.0
|
|
9
|
-
License-File: LICENSE
|
|
9
|
+
License-File: LICENSE.txt
|
|
10
10
|
Classifier: Development Status :: 4 - Beta
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
17
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
18
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.11
|
|
21
20
|
Requires-Dist: chromadb>=1.5.4
|
|
22
21
|
Requires-Dist: haystack-ai>=2.28.0
|
|
23
22
|
Description-Content-Type: text/markdown
|
|
@@ -36,5 +35,5 @@ Description-Content-Type: text/markdown
|
|
|
36
35
|
|
|
37
36
|
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
38
37
|
|
|
39
|
-
To run integration tests locally, you need a Chroma server running
|
|
40
|
-
|
|
38
|
+
To run integration tests locally, you need a Chroma server running on `localhost:8000`.
|
|
39
|
+
You can start it with: `hatch run chroma run`.
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
14
14
|
|
|
15
|
-
To run integration tests locally, you need a Chroma server running
|
|
16
|
-
|
|
15
|
+
To run integration tests locally, you need a Chroma server running on `localhost:8000`.
|
|
16
|
+
You can start it with: `hatch run chroma run`.
|
|
@@ -7,7 +7,7 @@ name = "chroma-haystack"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = ''
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
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,7 +15,6 @@ 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",
|
|
@@ -135,6 +134,7 @@ ignore = [
|
|
|
135
134
|
"PLR0912",
|
|
136
135
|
"PLR0913",
|
|
137
136
|
"PLR0915",
|
|
137
|
+
"PLR0917",
|
|
138
138
|
# Ignore unused params
|
|
139
139
|
"ARG002",
|
|
140
140
|
# Allow assertions
|
|
@@ -362,7 +362,7 @@ class ChromaDocumentStore:
|
|
|
362
362
|
search_term: str | None,
|
|
363
363
|
from_: int,
|
|
364
364
|
size: int,
|
|
365
|
-
) -> tuple[list[
|
|
365
|
+
) -> tuple[list[Any], int]:
|
|
366
366
|
"""
|
|
367
367
|
Computes paginated unique values for a metadata field from a Chroma get result.
|
|
368
368
|
|
|
@@ -372,7 +372,7 @@ class ChromaDocumentStore:
|
|
|
372
372
|
substring against the value of `field_name`.
|
|
373
373
|
:param from_: The offset to start returning values from.
|
|
374
374
|
:param size: The maximum number of unique values to return.
|
|
375
|
-
:returns: A tuple of the paginated unique values list and the total count.
|
|
375
|
+
:returns: A tuple of the paginated unique values (in their original type) list and the total count.
|
|
376
376
|
"""
|
|
377
377
|
metadatas = result.get("metadatas", [])
|
|
378
378
|
|
|
@@ -393,13 +393,22 @@ class ChromaDocumentStore:
|
|
|
393
393
|
if not metadatas:
|
|
394
394
|
return [], 0
|
|
395
395
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
# Values of different types can be equal in Python (`1 == True`, `1 == 1.0`), so a plain set
|
|
397
|
+
# would silently merge them. Dedupe by (type, value) instead to keep them distinct.
|
|
398
|
+
seen: set[tuple[type, Any]] = set()
|
|
399
|
+
unique_values: list[Any] = []
|
|
400
|
+
for meta in metadatas:
|
|
401
|
+
if not meta or field_name not in meta:
|
|
402
|
+
continue
|
|
403
|
+
value = meta.get(field_name)
|
|
404
|
+
if value is None:
|
|
405
|
+
continue
|
|
406
|
+
dedup_key = (type(value), value)
|
|
407
|
+
if dedup_key not in seen:
|
|
408
|
+
seen.add(dedup_key)
|
|
409
|
+
unique_values.append(value)
|
|
401
410
|
|
|
402
|
-
sorted_values = sorted(unique_values)
|
|
411
|
+
sorted_values = sorted(unique_values, key=str)
|
|
403
412
|
total_count = len(sorted_values)
|
|
404
413
|
end = from_ + size
|
|
405
414
|
paginated_values = sorted_values[from_:end]
|
|
@@ -1308,7 +1317,8 @@ class ChromaDocumentStore:
|
|
|
1308
1317
|
search_term: str | None = None,
|
|
1309
1318
|
from_: int = 0,
|
|
1310
1319
|
size: int = 10,
|
|
1311
|
-
|
|
1320
|
+
filters: dict[str, Any] | None = None,
|
|
1321
|
+
) -> tuple[list[Any], int]:
|
|
1312
1322
|
"""
|
|
1313
1323
|
Return unique metadata field values, optionally filtered by a search term, with pagination.
|
|
1314
1324
|
|
|
@@ -1318,14 +1328,17 @@ class ChromaDocumentStore:
|
|
|
1318
1328
|
case-insensitive substring against the metadata field's value.
|
|
1319
1329
|
:param from_: The offset to start returning values from (for pagination).
|
|
1320
1330
|
:param size: The maximum number of unique values to return.
|
|
1321
|
-
:
|
|
1331
|
+
:param filters: Optional filters to restrict the documents considered.
|
|
1332
|
+
:returns: A tuple containing list of unique values (in their original type) and total count of unique values.
|
|
1322
1333
|
"""
|
|
1323
1334
|
self._ensure_initialized()
|
|
1324
1335
|
assert self._collection is not None
|
|
1325
1336
|
|
|
1326
1337
|
field_name = _normalize_metadata_field_name(metadata_field)
|
|
1327
1338
|
|
|
1328
|
-
|
|
1339
|
+
kwargs = ChromaDocumentStore._prepare_get_kwargs(filters)
|
|
1340
|
+
kwargs["include"] = ["metadatas"]
|
|
1341
|
+
result = self._collection.get(**kwargs)
|
|
1329
1342
|
return self._compute_field_unique_values(result, field_name, search_term, from_, size)
|
|
1330
1343
|
|
|
1331
1344
|
async def get_metadata_field_unique_values_async(
|
|
@@ -1334,7 +1347,8 @@ class ChromaDocumentStore:
|
|
|
1334
1347
|
search_term: str | None = None,
|
|
1335
1348
|
from_: int = 0,
|
|
1336
1349
|
size: int = 10,
|
|
1337
|
-
|
|
1350
|
+
filters: dict[str, Any] | None = None,
|
|
1351
|
+
) -> tuple[list[Any], int]:
|
|
1338
1352
|
"""
|
|
1339
1353
|
Asynchronously return unique metadata field values, optionally filtered by a search term, with pagination.
|
|
1340
1354
|
|
|
@@ -1346,14 +1360,17 @@ class ChromaDocumentStore:
|
|
|
1346
1360
|
case-insensitive substring against the metadata field's value.
|
|
1347
1361
|
:param from_: The offset to start returning values from (for pagination).
|
|
1348
1362
|
:param size: The maximum number of unique values to return.
|
|
1349
|
-
:
|
|
1363
|
+
:param filters: Optional filters to restrict the documents considered.
|
|
1364
|
+
:returns: A tuple containing list of unique values (in their original type) and total count of unique values.
|
|
1350
1365
|
"""
|
|
1351
1366
|
await self._ensure_initialized_async()
|
|
1352
1367
|
assert self._async_collection is not None
|
|
1353
1368
|
|
|
1354
1369
|
field_name = _normalize_metadata_field_name(metadata_field)
|
|
1355
1370
|
|
|
1356
|
-
|
|
1371
|
+
kwargs = ChromaDocumentStore._prepare_get_kwargs(filters)
|
|
1372
|
+
kwargs["include"] = ["metadatas"]
|
|
1373
|
+
result = await self._async_collection.get(**kwargs)
|
|
1357
1374
|
return self._compute_field_unique_values(result, field_name, search_term, from_, size)
|
|
1358
1375
|
|
|
1359
1376
|
@classmethod
|
|
@@ -752,108 +752,6 @@ class TestMetadataOperations:
|
|
|
752
752
|
assert min_max["min"] is None
|
|
753
753
|
assert min_max["max"] is None
|
|
754
754
|
|
|
755
|
-
def test_get_metadata_field_unique_values_basic(self, populated_store):
|
|
756
|
-
"""Test getting unique values for metadata field"""
|
|
757
|
-
values, total = populated_store.get_metadata_field_unique_values("category", from_=0, size=10)
|
|
758
|
-
assert sorted(values) == ["A", "B", "C"]
|
|
759
|
-
assert total == 3
|
|
760
|
-
|
|
761
|
-
def test_get_metadata_field_unique_values_pagination(self, populated_store):
|
|
762
|
-
"""Test pagination of unique values"""
|
|
763
|
-
# First page
|
|
764
|
-
values_page1, total = populated_store.get_metadata_field_unique_values("category", from_=0, size=2)
|
|
765
|
-
assert len(values_page1) == 2
|
|
766
|
-
assert total == 3
|
|
767
|
-
|
|
768
|
-
# Second page
|
|
769
|
-
values_page2, total = populated_store.get_metadata_field_unique_values("category", from_=2, size=2)
|
|
770
|
-
assert len(values_page2) == 1
|
|
771
|
-
assert total == 3
|
|
772
|
-
|
|
773
|
-
# Check all values are returned across pages
|
|
774
|
-
all_values = values_page1 + values_page2
|
|
775
|
-
assert sorted(all_values) == ["A", "B", "C"]
|
|
776
|
-
|
|
777
|
-
def test_get_metadata_field_unique_values_with_search_term(self, populated_store):
|
|
778
|
-
"""Test getting unique values filtered by search term.
|
|
779
|
-
|
|
780
|
-
The search term is matched against the metadata field's own value, not document
|
|
781
|
-
content. "Doc 1" is content for one document (category "A"), but it is not a
|
|
782
|
-
substring of any "category" value, so no values should match.
|
|
783
|
-
"""
|
|
784
|
-
values, total = populated_store.get_metadata_field_unique_values(
|
|
785
|
-
"category", search_term="Doc 1", from_=0, size=10
|
|
786
|
-
)
|
|
787
|
-
assert values == []
|
|
788
|
-
assert total == 0
|
|
789
|
-
|
|
790
|
-
def test_get_metadata_field_unique_values_search_term_matches_field_value(self, populated_store):
|
|
791
|
-
"""Search term matches when it's a case-insensitive substring of the field's value."""
|
|
792
|
-
values, total = populated_store.get_metadata_field_unique_values("status", search_term="ACT", from_=0, size=10)
|
|
793
|
-
# "ACT" is a substring of both "active" and "inactive" (case-insensitive)
|
|
794
|
-
assert sorted(values) == ["active", "inactive"]
|
|
795
|
-
assert total == 2
|
|
796
|
-
|
|
797
|
-
values, total = populated_store.get_metadata_field_unique_values("status", search_term="ina", from_=0, size=10)
|
|
798
|
-
assert values == ["inactive"]
|
|
799
|
-
assert total == 1
|
|
800
|
-
|
|
801
|
-
def test_get_metadata_field_unique_values_search_term_excludes_content_only_match(self, document_store):
|
|
802
|
-
"""A search term present only in document content (not in the metadata field value)
|
|
803
|
-
must not match, proving search_term no longer filters on content."""
|
|
804
|
-
docs = [
|
|
805
|
-
Document(content="unique-marker-xyz", meta={"category": "A"}),
|
|
806
|
-
Document(content="plain content", meta={"category": "B"}),
|
|
807
|
-
]
|
|
808
|
-
document_store.write_documents(docs)
|
|
809
|
-
|
|
810
|
-
values, total = document_store.get_metadata_field_unique_values(
|
|
811
|
-
"category", search_term="unique-marker-xyz", from_=0, size=10
|
|
812
|
-
)
|
|
813
|
-
assert values == []
|
|
814
|
-
assert total == 0
|
|
815
|
-
|
|
816
|
-
def test_get_metadata_field_unique_values_search_term_matches_field_value_not_content(self, document_store):
|
|
817
|
-
"""A search term present in the metadata field's value but absent from the content
|
|
818
|
-
must match, proving search_term filters on the metadata field's value."""
|
|
819
|
-
docs = [
|
|
820
|
-
Document(content="Nothing special here", meta={"category": "special-value"}),
|
|
821
|
-
Document(content="Nothing special here either", meta={"category": "other"}),
|
|
822
|
-
]
|
|
823
|
-
document_store.write_documents(docs)
|
|
824
|
-
|
|
825
|
-
values, total = document_store.get_metadata_field_unique_values(
|
|
826
|
-
"category", search_term="SPECIAL", from_=0, size=10
|
|
827
|
-
)
|
|
828
|
-
assert values == ["special-value"]
|
|
829
|
-
assert total == 1
|
|
830
|
-
|
|
831
|
-
def test_get_metadata_field_unique_values_field_normalization(self, populated_store):
|
|
832
|
-
"""Test field name normalization in unique values"""
|
|
833
|
-
# Test with "meta." prefix
|
|
834
|
-
values_with_prefix, total_with_prefix = populated_store.get_metadata_field_unique_values(
|
|
835
|
-
"meta.category", from_=0, size=10
|
|
836
|
-
)
|
|
837
|
-
# Test without "meta." prefix
|
|
838
|
-
values_without_prefix, total_without_prefix = populated_store.get_metadata_field_unique_values(
|
|
839
|
-
"category", from_=0, size=10
|
|
840
|
-
)
|
|
841
|
-
|
|
842
|
-
assert sorted(values_with_prefix) == sorted(values_without_prefix) == ["A", "B", "C"]
|
|
843
|
-
assert total_with_prefix == total_without_prefix == 3
|
|
844
|
-
|
|
845
|
-
def test_get_metadata_field_unique_values_missing_field(self, populated_store):
|
|
846
|
-
"""Test getting unique values for non-existent field"""
|
|
847
|
-
values, total = populated_store.get_metadata_field_unique_values("nonexistent_field", from_=0, size=10)
|
|
848
|
-
assert values == []
|
|
849
|
-
assert total == 0
|
|
850
|
-
|
|
851
|
-
def test_get_metadata_field_unique_values_empty_collection(self, document_store):
|
|
852
|
-
"""Test getting unique values from empty collection"""
|
|
853
|
-
values, total = document_store.get_metadata_field_unique_values("category", from_=0, size=10)
|
|
854
|
-
assert values == []
|
|
855
|
-
assert total == 0
|
|
856
|
-
|
|
857
755
|
def test_get_metadata_field_unique_values_sorting(self, populated_store):
|
|
858
756
|
"""Test that unique values are sorted consistently"""
|
|
859
757
|
values, total = populated_store.get_metadata_field_unique_values("status", from_=0, size=10)
|
|
@@ -123,7 +123,7 @@ class TestDocumentStoreAsync(
|
|
|
123
123
|
assert store._async_client.get_settings().anonymized_telemetry is False
|
|
124
124
|
|
|
125
125
|
async def test_search_async(self):
|
|
126
|
-
document_store = ChromaDocumentStore(host="localhost", port=8000, collection_name="
|
|
126
|
+
document_store = ChromaDocumentStore(host="localhost", port=8000, collection_name=f"{uuid.uuid1()}-search")
|
|
127
127
|
|
|
128
128
|
documents = [
|
|
129
129
|
Document(content="First document", meta={"author": "Author1"}),
|
|
@@ -205,47 +205,3 @@ class TestDocumentStoreAsync(
|
|
|
205
205
|
min_max = await document_store.get_metadata_field_min_max_async("nonexistent_field")
|
|
206
206
|
assert min_max["min"] is None
|
|
207
207
|
assert min_max["max"] is None
|
|
208
|
-
|
|
209
|
-
async def test_get_metadata_field_unique_values_async_missing_field(self, document_store: ChromaDocumentStore):
|
|
210
|
-
"""Chroma-specific: unique values for non-existent field returns empty."""
|
|
211
|
-
docs = [Document(content="Doc 1", meta={"category": "A"})]
|
|
212
|
-
await document_store.write_documents_async(docs)
|
|
213
|
-
values, total = await document_store.get_metadata_field_unique_values_async(
|
|
214
|
-
"nonexistent_field", from_=0, size=10
|
|
215
|
-
)
|
|
216
|
-
assert values == []
|
|
217
|
-
assert total == 0
|
|
218
|
-
|
|
219
|
-
async def test_get_metadata_field_unique_values_async_search_term_excludes_content_only_match(
|
|
220
|
-
self, document_store: ChromaDocumentStore
|
|
221
|
-
):
|
|
222
|
-
"""A search term present only in document content (not in the metadata field value)
|
|
223
|
-
must not match, proving search_term no longer filters on content."""
|
|
224
|
-
docs = [
|
|
225
|
-
Document(content="unique-marker-xyz", meta={"category": "A"}),
|
|
226
|
-
Document(content="plain content", meta={"category": "B"}),
|
|
227
|
-
]
|
|
228
|
-
await document_store.write_documents_async(docs)
|
|
229
|
-
|
|
230
|
-
values, total = await document_store.get_metadata_field_unique_values_async(
|
|
231
|
-
"category", search_term="unique-marker-xyz", from_=0, size=10
|
|
232
|
-
)
|
|
233
|
-
assert values == []
|
|
234
|
-
assert total == 0
|
|
235
|
-
|
|
236
|
-
async def test_get_metadata_field_unique_values_async_search_term_matches_field_value(
|
|
237
|
-
self, document_store: ChromaDocumentStore
|
|
238
|
-
):
|
|
239
|
-
"""A search term present in the metadata field's value but absent from the content
|
|
240
|
-
must match, proving search_term filters on the metadata field's value (case-insensitively)."""
|
|
241
|
-
docs = [
|
|
242
|
-
Document(content="Nothing special here", meta={"category": "special-value"}),
|
|
243
|
-
Document(content="Nothing special here either", meta={"category": "other"}),
|
|
244
|
-
]
|
|
245
|
-
await document_store.write_documents_async(docs)
|
|
246
|
-
|
|
247
|
-
values, total = await document_store.get_metadata_field_unique_values_async(
|
|
248
|
-
"category", search_term="SPECIAL", from_=0, size=10
|
|
249
|
-
)
|
|
250
|
-
assert values == ["special-value"]
|
|
251
|
-
assert total == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{chroma_haystack-4.4.0 → chroma_haystack-5.0.0}/src/haystack_integrations/document_stores/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|