pinecone-haystack 6.3.0__tar.gz → 6.4.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.
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/CHANGELOG.md +15 -0
- pinecone_haystack-6.4.0/LICENSE.txt +201 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/PKG-INFO +4 -3
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/pyproject.toml +2 -1
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/document_stores/pinecone/document_store.py +50 -16
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/test_document_store.py +58 -36
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/test_document_store_async.py +41 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/.gitignore +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/README.md +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/examples/example.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/pydoc/config_docusaurus.yml +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/components/retrievers/pinecone/__init__.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/components/retrievers/pinecone/embedding_retriever.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/document_stores/pinecone/__init__.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/document_stores/pinecone/filters.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/__init__.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/conftest.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/test_embedding_retriever.py +0 -0
- {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.0}/tests/test_filters.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/pinecone-v6.3.0] - 2026-07-22
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- Replace in-place dataclass mutations in anthropic, llama_cpp, olama, pinecone tests (#3551)
|
|
8
|
+
|
|
9
|
+
### 🚜 Refactor
|
|
10
|
+
|
|
11
|
+
- Align Pinecone closing methods to standard (#3629)
|
|
12
|
+
|
|
13
|
+
### 📚 Documentation
|
|
14
|
+
|
|
15
|
+
- Replace old haystack core imports with haystack_integrations paths (#3545)
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## [integrations/pinecone-v6.2.0] - 2026-05-08
|
|
4
19
|
|
|
5
20
|
### 🐛 Bug Fixes
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023-present deepset GmbH
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 6.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pinecone-haystack
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/pinecone#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/pinecone
|
|
7
7
|
Author-email: deepset GmbH <info@deepset.ai>
|
|
8
8
|
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE.txt
|
|
9
10
|
Classifier: Development Status :: 4 - Beta
|
|
10
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
12
|
Classifier: Programming Language :: Python
|
|
@@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"]
|
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "
|
|
6
|
+
name = "pinecone-haystack"
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = ''
|
|
9
9
|
readme = "README.md"
|
|
@@ -140,6 +140,7 @@ ignore = [
|
|
|
140
140
|
"PLR0912",
|
|
141
141
|
"PLR0913",
|
|
142
142
|
"PLR0915",
|
|
143
|
+
"PLR0917",
|
|
143
144
|
# Ignore assertions
|
|
144
145
|
"S101",
|
|
145
146
|
]
|
|
@@ -891,25 +891,37 @@ class PineconeDocumentStore:
|
|
|
891
891
|
@staticmethod
|
|
892
892
|
def _get_metadata_field_unique_values_impl(
|
|
893
893
|
documents: list[Document], metadata_field: str, search_term: str | None, from_: int, size: int
|
|
894
|
-
) -> tuple[list[
|
|
894
|
+
) -> tuple[list[Any], int]:
|
|
895
895
|
"""Helper method to get unique values for a metadata field with search and pagination."""
|
|
896
|
-
|
|
896
|
+
field_name = metadata_field.removeprefix("meta.")
|
|
897
|
+
# Values of different types can be equal in Python (`1 == True`, `1 == 1.0`), so a plain set
|
|
898
|
+
# would silently merge them. Dedupe by (type, value) instead to keep them distinct.
|
|
899
|
+
seen: set[tuple[type, Any]] = set()
|
|
900
|
+
unique_values: list[Any] = []
|
|
901
|
+
|
|
902
|
+
def _add(value: Any) -> None:
|
|
903
|
+
dedup_key = (type(value), value)
|
|
904
|
+
if dedup_key not in seen:
|
|
905
|
+
seen.add(dedup_key)
|
|
906
|
+
unique_values.append(value)
|
|
907
|
+
|
|
897
908
|
for doc in documents:
|
|
898
|
-
if doc.meta and
|
|
899
|
-
value = doc.meta[
|
|
909
|
+
if doc.meta and field_name in doc.meta:
|
|
910
|
+
value = doc.meta[field_name]
|
|
900
911
|
# Handle list values
|
|
901
912
|
if isinstance(value, list):
|
|
902
|
-
|
|
913
|
+
for item in value:
|
|
914
|
+
_add(item)
|
|
903
915
|
else:
|
|
904
|
-
|
|
916
|
+
_add(value)
|
|
905
917
|
|
|
906
918
|
# Convert to sorted list
|
|
907
|
-
unique_values_list = sorted(unique_values)
|
|
919
|
+
unique_values_list = sorted(unique_values, key=str)
|
|
908
920
|
|
|
909
921
|
# Apply search term filter if provided
|
|
910
922
|
if search_term:
|
|
911
923
|
search_term_lower = search_term.lower()
|
|
912
|
-
unique_values_list = [v for v in unique_values_list if search_term_lower in v.lower()]
|
|
924
|
+
unique_values_list = [v for v in unique_values_list if search_term_lower in str(v).lower()]
|
|
913
925
|
|
|
914
926
|
total_count = len(unique_values_list)
|
|
915
927
|
|
|
@@ -1069,37 +1081,59 @@ class PineconeDocumentStore:
|
|
|
1069
1081
|
return self._get_metadata_field_min_max_impl(documents, metadata_field)
|
|
1070
1082
|
|
|
1071
1083
|
def get_metadata_field_unique_values(
|
|
1072
|
-
self,
|
|
1073
|
-
|
|
1084
|
+
self,
|
|
1085
|
+
metadata_field: str,
|
|
1086
|
+
search_term: str | None = None,
|
|
1087
|
+
from_: int = 0,
|
|
1088
|
+
size: int = 10,
|
|
1089
|
+
filters: dict[str, Any] | None = None,
|
|
1090
|
+
) -> tuple[list[Any], int]:
|
|
1074
1091
|
"""
|
|
1075
1092
|
Retrieves unique values for a metadata field with optional search and pagination.
|
|
1076
1093
|
|
|
1077
1094
|
Note: This method fetches documents and extracts unique values in Python.
|
|
1078
1095
|
Subject to Pinecone's TOP_K_LIMIT of 1000 documents.
|
|
1079
1096
|
|
|
1097
|
+
Note: Pinecone stores numeric metadata values as `float` (see `_convert_meta_to_int`), so an
|
|
1098
|
+
int written for an arbitrary field may come back as a numerically equal float rather than int.
|
|
1099
|
+
Values of different types are otherwise kept distinct even when they compare equal in Python
|
|
1100
|
+
(e.g. the int `1` and the bool `True` are returned as two separate values).
|
|
1101
|
+
|
|
1080
1102
|
:param metadata_field: The metadata field name to get unique values for.
|
|
1081
1103
|
:param search_term: Optional search term to filter values (case-insensitive substring match).
|
|
1082
1104
|
:param from_: Starting offset for pagination (default: 0).
|
|
1083
1105
|
:param size: Number of values to return (default: 10).
|
|
1084
|
-
:
|
|
1106
|
+
:param filters: Optional filters to restrict the documents considered.
|
|
1107
|
+
:returns: Tuple of (list of unique values in their original type, total count of matching values).
|
|
1085
1108
|
"""
|
|
1086
|
-
documents = self.filter_documents(filters=
|
|
1109
|
+
documents = self.filter_documents(filters=filters)
|
|
1087
1110
|
return self._get_metadata_field_unique_values_impl(documents, metadata_field, search_term, from_, size)
|
|
1088
1111
|
|
|
1089
1112
|
async def get_metadata_field_unique_values_async(
|
|
1090
|
-
self,
|
|
1091
|
-
|
|
1113
|
+
self,
|
|
1114
|
+
metadata_field: str,
|
|
1115
|
+
search_term: str | None = None,
|
|
1116
|
+
from_: int = 0,
|
|
1117
|
+
size: int = 10,
|
|
1118
|
+
filters: dict[str, Any] | None = None,
|
|
1119
|
+
) -> tuple[list[Any], int]:
|
|
1092
1120
|
"""
|
|
1093
1121
|
Asynchronously retrieves unique values for a metadata field with optional search and pagination.
|
|
1094
1122
|
|
|
1095
1123
|
Note: This method fetches documents and extracts unique values in Python.
|
|
1096
1124
|
Subject to Pinecone's TOP_K_LIMIT of 1000 documents.
|
|
1097
1125
|
|
|
1126
|
+
Note: Pinecone stores numeric metadata values as `float` (see `_convert_meta_to_int`), so an
|
|
1127
|
+
int written for an arbitrary field may come back as a numerically equal float rather than int.
|
|
1128
|
+
Values of different types are otherwise kept distinct even when they compare equal in Python
|
|
1129
|
+
(e.g. the int `1` and the bool `True` are returned as two separate values).
|
|
1130
|
+
|
|
1098
1131
|
:param metadata_field: The metadata field name to get unique values for.
|
|
1099
1132
|
:param search_term: Optional search term to filter values (case-insensitive substring match).
|
|
1100
1133
|
:param from_: Starting offset for pagination (default: 0).
|
|
1101
1134
|
:param size: Number of values to return (default: 10).
|
|
1102
|
-
:
|
|
1135
|
+
:param filters: Optional filters to restrict the documents considered.
|
|
1136
|
+
:returns: Tuple of (list of unique values in their original type, total count of matching values).
|
|
1103
1137
|
"""
|
|
1104
|
-
documents = await self.filter_documents_async(filters=
|
|
1138
|
+
documents = await self.filter_documents_async(filters=filters)
|
|
1105
1139
|
return self._get_metadata_field_unique_values_impl(documents, metadata_field, search_term, from_, size)
|
|
@@ -339,6 +339,32 @@ def test_get_metadata_field_unique_values_impl_pagination_search_and_lists():
|
|
|
339
339
|
assert values == ["python"]
|
|
340
340
|
|
|
341
341
|
|
|
342
|
+
def test_get_metadata_field_unique_values_impl_preserves_non_string_types():
|
|
343
|
+
docs = [
|
|
344
|
+
Document(content="a", meta={"priority": 1}),
|
|
345
|
+
Document(content="b", meta={"priority": 2}),
|
|
346
|
+
Document(content="c", meta={"priority": 1}),
|
|
347
|
+
]
|
|
348
|
+
|
|
349
|
+
values, total = PineconeDocumentStore._get_metadata_field_unique_values_impl(
|
|
350
|
+
docs, "priority", search_term=None, from_=0, size=10
|
|
351
|
+
)
|
|
352
|
+
assert total == 2
|
|
353
|
+
assert set(values) == {1, 2}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def test_get_metadata_field_unique_values_impl_strips_meta_prefix():
|
|
357
|
+
docs = [
|
|
358
|
+
Document(content="a", meta={"category": "news"}),
|
|
359
|
+
Document(content="b", meta={"category": "sports"}),
|
|
360
|
+
]
|
|
361
|
+
values, total = PineconeDocumentStore._get_metadata_field_unique_values_impl(
|
|
362
|
+
docs, "meta.category", search_term=None, from_=0, size=10
|
|
363
|
+
)
|
|
364
|
+
assert total == 2
|
|
365
|
+
assert values == ["news", "sports"]
|
|
366
|
+
|
|
367
|
+
|
|
342
368
|
def test_prepare_documents_for_writing_edge_cases(caplog):
|
|
343
369
|
ds = PineconeDocumentStore(api_key=Secret.from_token("fake-api-key"))
|
|
344
370
|
|
|
@@ -426,6 +452,38 @@ class TestDocumentStore(
|
|
|
426
452
|
docs = [Document(id="1")]
|
|
427
453
|
assert document_store.write_documents(docs) == 1
|
|
428
454
|
|
|
455
|
+
def test_get_metadata_field_unique_values_distinct_types(self, document_store: PineconeDocumentStore):
|
|
456
|
+
"""
|
|
457
|
+
Override: the base mixin test stores int, float, str and bool under the *same* metadata field
|
|
458
|
+
name and expects all four back as distinct values. Pinecone stores numeric metadata values as
|
|
459
|
+
`float` (see `_convert_meta_to_int`), so an int written for an arbitrary field may come back as
|
|
460
|
+
a numerically equal float instead - collapsing with a genuine float under the same field name
|
|
461
|
+
regardless of which other values share that field.
|
|
462
|
+
|
|
463
|
+
This adapts the same intent - int, float, str and bool must come back as distinct, unmangled
|
|
464
|
+
types via get_metadata_field_unique_values() - using one field per type instead of one shared
|
|
465
|
+
field, which is what Pinecone can actually support.
|
|
466
|
+
"""
|
|
467
|
+
docs = [
|
|
468
|
+
Document(content="Doc 1", meta={"priority_int": 1}),
|
|
469
|
+
Document(content="Doc 2", meta={"priority_str": "1"}),
|
|
470
|
+
Document(content="Doc 3", meta={"priority_float": 1.5}),
|
|
471
|
+
Document(content="Doc 4", meta={"priority_bool": True}),
|
|
472
|
+
]
|
|
473
|
+
document_store.write_documents(docs)
|
|
474
|
+
|
|
475
|
+
int_values, int_count = document_store.get_metadata_field_unique_values(metadata_field="priority_int")
|
|
476
|
+
str_values, str_count = document_store.get_metadata_field_unique_values(metadata_field="priority_str")
|
|
477
|
+
float_values, float_count = document_store.get_metadata_field_unique_values(metadata_field="priority_float")
|
|
478
|
+
bool_values, bool_count = document_store.get_metadata_field_unique_values(metadata_field="priority_bool")
|
|
479
|
+
|
|
480
|
+
assert (int_count, str_count, float_count, bool_count) == (1, 1, 1, 1)
|
|
481
|
+
assert str_values == ["1"] and type(str_values[0]) is str
|
|
482
|
+
assert float_values == [1.5] and type(float_values[0]) is float
|
|
483
|
+
assert bool_values == [True] and type(bool_values[0]) is bool
|
|
484
|
+
# Pinecone may return a whole-number int as a numerically equal float (see docstring note above).
|
|
485
|
+
assert int_values[0] == 1 and type(int_values[0]) in (int, float)
|
|
486
|
+
|
|
429
487
|
@pytest.mark.xfail(
|
|
430
488
|
run=True, reason="Pinecone supports overwriting by default, but it takes a while for it to take effect"
|
|
431
489
|
)
|
|
@@ -542,42 +600,6 @@ class TestDocumentStore(
|
|
|
542
600
|
# Non-existent field
|
|
543
601
|
assert document_store.get_metadata_field_min_max("nonexistent") == {"min": None, "max": None}
|
|
544
602
|
|
|
545
|
-
def test_get_metadata_field_unique_values(self, document_store: PineconeDocumentStore):
|
|
546
|
-
docs = [
|
|
547
|
-
Document(content="Doc 1", meta={"category": "Alpha"}),
|
|
548
|
-
Document(content="Doc 2", meta={"category": "Beta"}),
|
|
549
|
-
Document(content="Doc 3", meta={"category": "Gamma"}),
|
|
550
|
-
Document(content="Doc 4", meta={"category": "Alpha"}),
|
|
551
|
-
Document(content="Doc 5", meta={"category": "Delta"}),
|
|
552
|
-
Document(content="Doc 6", meta={"category": "Beta"}),
|
|
553
|
-
]
|
|
554
|
-
document_store.write_documents(docs)
|
|
555
|
-
|
|
556
|
-
# Get all unique values
|
|
557
|
-
values, total = document_store.get_metadata_field_unique_values("category", from_=0, size=10)
|
|
558
|
-
assert total == 4 # Alpha, Beta, Delta, Gamma
|
|
559
|
-
assert len(values) == 4
|
|
560
|
-
assert set(values) == {"Alpha", "Beta", "Delta", "Gamma"}
|
|
561
|
-
|
|
562
|
-
# Test pagination
|
|
563
|
-
values, total = document_store.get_metadata_field_unique_values("category", from_=0, size=2)
|
|
564
|
-
assert total == 4
|
|
565
|
-
assert len(values) == 2 # First 2 values (alphabetically sorted)
|
|
566
|
-
|
|
567
|
-
values, total = document_store.get_metadata_field_unique_values("category", from_=2, size=2)
|
|
568
|
-
assert total == 4
|
|
569
|
-
assert len(values) == 2 # Next 2 values
|
|
570
|
-
|
|
571
|
-
# Test search term
|
|
572
|
-
values, total = document_store.get_metadata_field_unique_values("category", search_term="ta", size=10)
|
|
573
|
-
assert total == 2 # Beta and Delta contain "ta"
|
|
574
|
-
assert set(values) == {"Beta", "Delta"}
|
|
575
|
-
|
|
576
|
-
# Test case-insensitive search
|
|
577
|
-
values, total = document_store.get_metadata_field_unique_values("category", search_term="ALPHA", size=10)
|
|
578
|
-
assert total == 1
|
|
579
|
-
assert values == ["Alpha"]
|
|
580
|
-
|
|
581
603
|
def test_get_metadata_field_unique_values_with_lists(self, document_store: PineconeDocumentStore):
|
|
582
604
|
docs = [
|
|
583
605
|
Document(content="Doc 1", meta={"tags": ["python", "java"]}),
|
|
@@ -126,6 +126,47 @@ class TestDocumentStoreAsync(
|
|
|
126
126
|
docs = [Document(id="1")]
|
|
127
127
|
assert await document_store.write_documents_async(docs) == 1
|
|
128
128
|
|
|
129
|
+
@pytest.mark.asyncio
|
|
130
|
+
async def test_get_metadata_field_unique_values_distinct_types_async(self, document_store: PineconeDocumentStore):
|
|
131
|
+
"""
|
|
132
|
+
Override: the base mixin test stores int, float, str and bool under the *same* metadata field
|
|
133
|
+
name and expects all four back as distinct values. Pinecone stores numeric metadata values as
|
|
134
|
+
`float` (see `_convert_meta_to_int`), so an int written for an arbitrary field may come back as
|
|
135
|
+
a numerically equal float instead - collapsing with a genuine float under the same field name
|
|
136
|
+
regardless of which other values share that field.
|
|
137
|
+
|
|
138
|
+
This adapts the same intent - int, float, str and bool must come back as distinct, unmangled
|
|
139
|
+
types via get_metadata_field_unique_values_async() - using one field per type instead of one
|
|
140
|
+
shared field, which is what Pinecone can actually support.
|
|
141
|
+
"""
|
|
142
|
+
docs = [
|
|
143
|
+
Document(content="Doc 1", meta={"priority_int": 1}),
|
|
144
|
+
Document(content="Doc 2", meta={"priority_str": "1"}),
|
|
145
|
+
Document(content="Doc 3", meta={"priority_float": 1.5}),
|
|
146
|
+
Document(content="Doc 4", meta={"priority_bool": True}),
|
|
147
|
+
]
|
|
148
|
+
await document_store.write_documents_async(docs)
|
|
149
|
+
|
|
150
|
+
int_values, int_count = await document_store.get_metadata_field_unique_values_async(
|
|
151
|
+
metadata_field="priority_int"
|
|
152
|
+
)
|
|
153
|
+
str_values, str_count = await document_store.get_metadata_field_unique_values_async(
|
|
154
|
+
metadata_field="priority_str"
|
|
155
|
+
)
|
|
156
|
+
float_values, float_count = await document_store.get_metadata_field_unique_values_async(
|
|
157
|
+
metadata_field="priority_float"
|
|
158
|
+
)
|
|
159
|
+
bool_values, bool_count = await document_store.get_metadata_field_unique_values_async(
|
|
160
|
+
metadata_field="priority_bool"
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
assert (int_count, str_count, float_count, bool_count) == (1, 1, 1, 1)
|
|
164
|
+
assert str_values == ["1"] and type(str_values[0]) is str
|
|
165
|
+
assert float_values == [1.5] and type(float_values[0]) is float
|
|
166
|
+
assert bool_values == [True] and type(bool_values[0]) is bool
|
|
167
|
+
# Pinecone may return a whole-number int as a numerically equal float (see docstring note above).
|
|
168
|
+
assert int_values[0] == 1 and type(int_values[0]) in (int, float)
|
|
169
|
+
|
|
129
170
|
@pytest.mark.skip(reason="Pinecone only supports UPSERT operations")
|
|
130
171
|
async def test_write_documents_duplicate_fail_async(self, document_store: PineconeDocumentStore): ...
|
|
131
172
|
|
|
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
|