pinecone-haystack 6.3.0__tar.gz → 6.4.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 (21) hide show
  1. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/CHANGELOG.md +90 -16
  2. pinecone_haystack-6.4.1/LICENSE.txt +201 -0
  3. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/PKG-INFO +4 -3
  4. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/pyproject.toml +2 -1
  5. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/document_stores/pinecone/document_store.py +54 -19
  6. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/test_document_store.py +63 -36
  7. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/test_document_store_async.py +41 -0
  8. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/.gitignore +0 -0
  9. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/README.md +0 -0
  10. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/examples/example.py +0 -0
  11. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/pydoc/config_docusaurus.yml +0 -0
  12. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/components/retrievers/pinecone/__init__.py +0 -0
  13. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/components/retrievers/pinecone/embedding_retriever.py +0 -0
  14. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/components/retrievers/py.typed +0 -0
  15. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/document_stores/pinecone/__init__.py +0 -0
  16. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/document_stores/pinecone/filters.py +0 -0
  17. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/src/haystack_integrations/document_stores/py.typed +0 -0
  18. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/__init__.py +0 -0
  19. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/conftest.py +0 -0
  20. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/test_embedding_retriever.py +0 -0
  21. {pinecone_haystack-6.3.0 → pinecone_haystack-6.4.1}/tests/test_filters.py +0 -0
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/pinecone-v6.4.0] - 2026-09-01
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - `PineCone` normalisation of .meta usage in `get_metadata_field_unique_values()` (#3641)
8
+ - Fix new issues raised by ruff 0.16.0 (#3670)
9
+ - `PineConeDocumentStore` get_metadata_field_unique_values setting list of values to return to `Any` (#3711)
10
+ - PineCone adding optional parameter `filters` to `get_metadata_field_unique_values()` (#3736)
11
+ - Standardize license files (#3771)
12
+
13
+ ### 🧪 Testing
14
+
15
+ - `PineConeDocumentStore` removing duplicated tests already covered by haystack Mixin tests (#3784)
16
+
17
+ ### 🧹 Chores
18
+
19
+ - Re-standardize READMEs (#3768)
20
+
21
+
22
+ ## [integrations/pinecone-v6.3.0] - 2026-07-22
23
+
24
+ ### 🐛 Bug Fixes
25
+
26
+ - Replace in-place dataclass mutations in anthropic, llama_cpp, olama, pinecone tests (#3551)
27
+
28
+ ### 🚜 Refactor
29
+
30
+ - Align Pinecone closing methods to standard (#3629)
31
+
32
+ ### 📚 Documentation
33
+
34
+ - Replace old haystack core imports with haystack_integrations paths (#3545)
35
+
36
+
3
37
  ## [integrations/pinecone-v6.2.0] - 2026-05-08
4
38
 
5
39
  ### 🐛 Bug Fixes
@@ -185,7 +219,6 @@
185
219
 
186
220
  ### 🧹 Chores
187
221
 
188
- - Pinecone - remove legacy filter support (#1069)
189
222
  - Update changelog after removing legacy filters (#1083)
190
223
  - Update ruff linting scripts and settings (#1105)
191
224
  - Inherit from `FilterDocumentsTestWithDataframe` in Document Stores (#1290)
@@ -195,23 +228,50 @@
195
228
  - Test: Pinecone - increase sleep time (#1307)
196
229
  - Chore!: pinecone - remove dataframe support (#1372)
197
230
 
231
+ ## [integrations/pinecone-v2.0.0] - 2024-09-12
232
+
233
+ ### 🧹 Chores
234
+
235
+ - Pinecone - remove legacy filter support (#1069)
236
+
237
+
198
238
  ## [integrations/pinecone-v1.2.3] - 2024-08-29
199
239
 
200
- ### 🚀 Features
240
+ ### 🐛 Bug Fixes
201
241
 
202
- - Add filter_policy to pinecone integration (#821)
242
+ - Converting `Pinecone` metadata fields from float back to int (#1034)
243
+
244
+
245
+ ## [integrations/pinecone-v1.2.2] - 2024-08-21
203
246
 
204
247
  ### 🐛 Bug Fixes
205
248
 
206
- - `pinecone` - Fallback to default filter policy when deserializing retrievers without the init parameter (#901)
207
249
  - Skip unsupported meta fields in PineconeDB (#1009)
208
- - Converting `Pinecone` metadata fields from float back to int (#1034)
209
250
 
210
251
  ### 🧪 Testing
211
252
 
212
- - Pinecone - fix `test_serverless_index_creation_from_scratch` (#806)
213
253
  - Do not retry tests in `hatch run test` command (#954)
214
254
 
255
+ ### 🌀 Miscellaneous
256
+
257
+ - Chore: Pinecone - fix import in conftest (#914)
258
+
259
+ ## [integrations/pinecone-v1.2.1] - 2024-07-17
260
+
261
+ ### 🐛 Bug Fixes
262
+
263
+ - `pinecone` - Fallback to default filter policy when deserializing retrievers without the init parameter (#901)
264
+
265
+ ## [integrations/pinecone-v1.2.0] - 2024-07-15
266
+
267
+ ### 🚀 Features
268
+
269
+ - Add filter_policy to pinecone integration (#821)
270
+
271
+ ### 🧪 Testing
272
+
273
+ - Pinecone - fix `test_serverless_index_creation_from_scratch` (#806)
274
+
215
275
  ### ⚙️ CI
216
276
 
217
277
  - Retry tests to reduce flakyness (#836)
@@ -224,7 +284,6 @@
224
284
 
225
285
  - Ci: add retry config to Pinecone test (#848)
226
286
  - Chore: Minor retriever pydoc fix (#884)
227
- - Chore: Pinecone - fix import in conftest (#914)
228
287
 
229
288
  ## [integrations/pinecone-v1.1.0] - 2024-06-11
230
289
 
@@ -258,16 +317,8 @@
258
317
  - Update category slug (#442)
259
318
  - Disable-class-def (#556)
260
319
 
261
- ### ⚙️ CI
262
-
263
- - Generate API docs for Pinecone (#359)
264
-
265
320
  ### 🌀 Miscellaneous
266
321
 
267
- - Pinecone - decrease concurrency in tests (#323)
268
- - Rename retriever (#396)
269
- - Fix imports in example (#398)
270
- - [Pinecone] Use Haystack Secrets (#420)
271
322
  - Pinecone - review docstrings and API reference (#503)
272
323
  - Make tests show coverage (#566)
273
324
  - Temporarily skip failing tests (#593)
@@ -275,6 +326,24 @@
275
326
  - Make Document Stores initially skip `SparseEmbedding` (#606)
276
327
  - Skip `test_write_documents_duplicate_overwrite` test (#637)
277
328
 
329
+ ## [integrations/pinecone-v0.4.0] - 2024-02-15
330
+
331
+ ### 🌀 Miscellaneous
332
+
333
+ - Fix imports in example (#398)
334
+ - [Pinecone] Use Haystack Secrets (#420)
335
+
336
+ ## [integrations/pinecone-v0.3.0] - 2024-02-12
337
+
338
+ ### ⚙️ CI
339
+
340
+ - Generate API docs for Pinecone (#359)
341
+
342
+ ### 🌀 Miscellaneous
343
+
344
+ - Pinecone - decrease concurrency in tests (#323)
345
+ - Rename retriever (#396)
346
+
278
347
  ## [integrations/pinecone-v0.2.1] - 2024-01-31
279
348
 
280
349
  ### 🐛 Bug Fixes
@@ -290,9 +359,14 @@
290
359
 
291
360
  ### 🌀 Miscellaneous
292
361
 
293
- - Pinecone - update import for beta5 (#236)
294
362
  - Change import paths (#256)
295
363
 
364
+ ## [integrations/pinecone-v0.1.1] - 2024-01-18
365
+
366
+ ### 🌀 Miscellaneous
367
+
368
+ - Pinecone - update import for beta5 (#236)
369
+
296
370
  ## [integrations/pinecone-v0.1.0] - 2024-01-17
297
371
 
298
372
  ### 🌀 Miscellaneous
@@ -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.4
2
- Name: pinecone_haystack
3
- Version: 6.3.0
1
+ Metadata-Version: 2.5
2
+ Name: pinecone-haystack
3
+ Version: 6.4.1
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 = "pinecone_haystack"
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
  ]
@@ -828,12 +828,13 @@ class PineconeDocumentStore:
828
828
  # For lists, check the type of elements if list is non-empty
829
829
  if value:
830
830
  # Sample first element to determine list type
831
- if isinstance(value[0], str):
831
+ # bool before int/float here too, same reason as above
832
+ if isinstance(value[0], bool):
833
+ field_samples[field].add("boolean")
834
+ elif isinstance(value[0], str):
832
835
  field_samples[field].add("keyword")
833
836
  elif isinstance(value[0], (int, float)):
834
837
  field_samples[field].add("long")
835
- elif isinstance(value[0], bool):
836
- field_samples[field].add("boolean")
837
838
  else:
838
839
  # Empty list, default to keyword
839
840
  field_samples[field].add("keyword")
@@ -891,25 +892,37 @@ class PineconeDocumentStore:
891
892
  @staticmethod
892
893
  def _get_metadata_field_unique_values_impl(
893
894
  documents: list[Document], metadata_field: str, search_term: str | None, from_: int, size: int
894
- ) -> tuple[list[str], int]:
895
+ ) -> tuple[list[Any], int]:
895
896
  """Helper method to get unique values for a metadata field with search and pagination."""
896
- unique_values: set[str] = set()
897
+ field_name = metadata_field.removeprefix("meta.")
898
+ # Values of different types can be equal in Python (`1 == True`, `1 == 1.0`), so a plain set
899
+ # would silently merge them. Dedupe by (type, value) instead to keep them distinct.
900
+ seen: set[tuple[type, Any]] = set()
901
+ unique_values: list[Any] = []
902
+
903
+ def _add(value: Any) -> None:
904
+ dedup_key = (type(value), value)
905
+ if dedup_key not in seen:
906
+ seen.add(dedup_key)
907
+ unique_values.append(value)
908
+
897
909
  for doc in documents:
898
- if doc.meta and metadata_field in doc.meta:
899
- value = doc.meta[metadata_field]
910
+ if doc.meta and field_name in doc.meta:
911
+ value = doc.meta[field_name]
900
912
  # Handle list values
901
913
  if isinstance(value, list):
902
- unique_values.update(str(v) for v in value)
914
+ for item in value:
915
+ _add(item)
903
916
  else:
904
- unique_values.add(str(value))
917
+ _add(value)
905
918
 
906
919
  # Convert to sorted list
907
- unique_values_list = sorted(unique_values)
920
+ unique_values_list = sorted(unique_values, key=str)
908
921
 
909
922
  # Apply search term filter if provided
910
923
  if search_term:
911
924
  search_term_lower = search_term.lower()
912
- unique_values_list = [v for v in unique_values_list if search_term_lower in v.lower()]
925
+ unique_values_list = [v for v in unique_values_list if search_term_lower in str(v).lower()]
913
926
 
914
927
  total_count = len(unique_values_list)
915
928
 
@@ -1069,37 +1082,59 @@ class PineconeDocumentStore:
1069
1082
  return self._get_metadata_field_min_max_impl(documents, metadata_field)
1070
1083
 
1071
1084
  def get_metadata_field_unique_values(
1072
- self, metadata_field: str, search_term: str | None = None, from_: int = 0, size: int = 10
1073
- ) -> tuple[list[str], int]:
1085
+ self,
1086
+ metadata_field: str,
1087
+ search_term: str | None = None,
1088
+ from_: int = 0,
1089
+ size: int = 10,
1090
+ filters: dict[str, Any] | None = None,
1091
+ ) -> tuple[list[Any], int]:
1074
1092
  """
1075
1093
  Retrieves unique values for a metadata field with optional search and pagination.
1076
1094
 
1077
1095
  Note: This method fetches documents and extracts unique values in Python.
1078
1096
  Subject to Pinecone's TOP_K_LIMIT of 1000 documents.
1079
1097
 
1098
+ Note: Pinecone stores numeric metadata values as `float` (see `_convert_meta_to_int`), so an
1099
+ int written for an arbitrary field may come back as a numerically equal float rather than int.
1100
+ Values of different types are otherwise kept distinct even when they compare equal in Python
1101
+ (e.g. the int `1` and the bool `True` are returned as two separate values).
1102
+
1080
1103
  :param metadata_field: The metadata field name to get unique values for.
1081
1104
  :param search_term: Optional search term to filter values (case-insensitive substring match).
1082
1105
  :param from_: Starting offset for pagination (default: 0).
1083
1106
  :param size: Number of values to return (default: 10).
1084
- :returns: Tuple of (list of unique values, total count of matching values).
1107
+ :param filters: Optional filters to restrict the documents considered.
1108
+ :returns: Tuple of (list of unique values in their original type, total count of matching values).
1085
1109
  """
1086
- documents = self.filter_documents(filters=None)
1110
+ documents = self.filter_documents(filters=filters)
1087
1111
  return self._get_metadata_field_unique_values_impl(documents, metadata_field, search_term, from_, size)
1088
1112
 
1089
1113
  async def get_metadata_field_unique_values_async(
1090
- self, metadata_field: str, search_term: str | None = None, from_: int = 0, size: int = 10
1091
- ) -> tuple[list[str], int]:
1114
+ self,
1115
+ metadata_field: str,
1116
+ search_term: str | None = None,
1117
+ from_: int = 0,
1118
+ size: int = 10,
1119
+ filters: dict[str, Any] | None = None,
1120
+ ) -> tuple[list[Any], int]:
1092
1121
  """
1093
1122
  Asynchronously retrieves unique values for a metadata field with optional search and pagination.
1094
1123
 
1095
1124
  Note: This method fetches documents and extracts unique values in Python.
1096
1125
  Subject to Pinecone's TOP_K_LIMIT of 1000 documents.
1097
1126
 
1127
+ Note: Pinecone stores numeric metadata values as `float` (see `_convert_meta_to_int`), so an
1128
+ int written for an arbitrary field may come back as a numerically equal float rather than int.
1129
+ Values of different types are otherwise kept distinct even when they compare equal in Python
1130
+ (e.g. the int `1` and the bool `True` are returned as two separate values).
1131
+
1098
1132
  :param metadata_field: The metadata field name to get unique values for.
1099
1133
  :param search_term: Optional search term to filter values (case-insensitive substring match).
1100
1134
  :param from_: Starting offset for pagination (default: 0).
1101
1135
  :param size: Number of values to return (default: 10).
1102
- :returns: Tuple of (list of unique values, total count of matching values).
1136
+ :param filters: Optional filters to restrict the documents considered.
1137
+ :returns: Tuple of (list of unique values in their original type, total count of matching values).
1103
1138
  """
1104
- documents = await self.filter_documents_async(filters=None)
1139
+ documents = await self.filter_documents_async(filters=filters)
1105
1140
  return self._get_metadata_field_unique_values_impl(documents, metadata_field, search_term, from_, size)
@@ -276,6 +276,11 @@ def test_convert_meta_to_int():
276
276
  {"counts": {"type": "long"}},
277
277
  None,
278
278
  ),
279
+ (
280
+ [Document(content=None, meta={"flags": [True, False]})],
281
+ {"flags": {"type": "boolean"}},
282
+ None,
283
+ ),
279
284
  (
280
285
  [Document(content=None, meta={"empty": []})],
281
286
  {"empty": {"type": "keyword"}},
@@ -339,6 +344,32 @@ def test_get_metadata_field_unique_values_impl_pagination_search_and_lists():
339
344
  assert values == ["python"]
340
345
 
341
346
 
347
+ def test_get_metadata_field_unique_values_impl_preserves_non_string_types():
348
+ docs = [
349
+ Document(content="a", meta={"priority": 1}),
350
+ Document(content="b", meta={"priority": 2}),
351
+ Document(content="c", meta={"priority": 1}),
352
+ ]
353
+
354
+ values, total = PineconeDocumentStore._get_metadata_field_unique_values_impl(
355
+ docs, "priority", search_term=None, from_=0, size=10
356
+ )
357
+ assert total == 2
358
+ assert set(values) == {1, 2}
359
+
360
+
361
+ def test_get_metadata_field_unique_values_impl_strips_meta_prefix():
362
+ docs = [
363
+ Document(content="a", meta={"category": "news"}),
364
+ Document(content="b", meta={"category": "sports"}),
365
+ ]
366
+ values, total = PineconeDocumentStore._get_metadata_field_unique_values_impl(
367
+ docs, "meta.category", search_term=None, from_=0, size=10
368
+ )
369
+ assert total == 2
370
+ assert values == ["news", "sports"]
371
+
372
+
342
373
  def test_prepare_documents_for_writing_edge_cases(caplog):
343
374
  ds = PineconeDocumentStore(api_key=Secret.from_token("fake-api-key"))
344
375
 
@@ -426,6 +457,38 @@ class TestDocumentStore(
426
457
  docs = [Document(id="1")]
427
458
  assert document_store.write_documents(docs) == 1
428
459
 
460
+ def test_get_metadata_field_unique_values_distinct_types(self, document_store: PineconeDocumentStore):
461
+ """
462
+ Override: the base mixin test stores int, float, str and bool under the *same* metadata field
463
+ name and expects all four back as distinct values. Pinecone stores numeric metadata values as
464
+ `float` (see `_convert_meta_to_int`), so an int written for an arbitrary field may come back as
465
+ a numerically equal float instead - collapsing with a genuine float under the same field name
466
+ regardless of which other values share that field.
467
+
468
+ This adapts the same intent - int, float, str and bool must come back as distinct, unmangled
469
+ types via get_metadata_field_unique_values() - using one field per type instead of one shared
470
+ field, which is what Pinecone can actually support.
471
+ """
472
+ docs = [
473
+ Document(content="Doc 1", meta={"priority_int": 1}),
474
+ Document(content="Doc 2", meta={"priority_str": "1"}),
475
+ Document(content="Doc 3", meta={"priority_float": 1.5}),
476
+ Document(content="Doc 4", meta={"priority_bool": True}),
477
+ ]
478
+ document_store.write_documents(docs)
479
+
480
+ int_values, int_count = document_store.get_metadata_field_unique_values(metadata_field="priority_int")
481
+ str_values, str_count = document_store.get_metadata_field_unique_values(metadata_field="priority_str")
482
+ float_values, float_count = document_store.get_metadata_field_unique_values(metadata_field="priority_float")
483
+ bool_values, bool_count = document_store.get_metadata_field_unique_values(metadata_field="priority_bool")
484
+
485
+ assert (int_count, str_count, float_count, bool_count) == (1, 1, 1, 1)
486
+ assert str_values == ["1"] and type(str_values[0]) is str
487
+ assert float_values == [1.5] and type(float_values[0]) is float
488
+ assert bool_values == [True] and type(bool_values[0]) is bool
489
+ # Pinecone may return a whole-number int as a numerically equal float (see docstring note above).
490
+ assert int_values[0] == 1 and type(int_values[0]) in (int, float)
491
+
429
492
  @pytest.mark.xfail(
430
493
  run=True, reason="Pinecone supports overwriting by default, but it takes a while for it to take effect"
431
494
  )
@@ -542,42 +605,6 @@ class TestDocumentStore(
542
605
  # Non-existent field
543
606
  assert document_store.get_metadata_field_min_max("nonexistent") == {"min": None, "max": None}
544
607
 
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
608
  def test_get_metadata_field_unique_values_with_lists(self, document_store: PineconeDocumentStore):
582
609
  docs = [
583
610
  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