opensearch-haystack 6.5.1__tar.gz → 7.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.
Files changed (33) hide show
  1. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/CHANGELOG.md +11 -0
  2. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/PKG-INFO +1 -1
  3. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/document_store.py +31 -23
  4. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_auth.py +2 -2
  5. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_bm25_retriever.py +4 -1
  6. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_document_store.py +72 -5
  7. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_embedding_retriever.py +4 -1
  8. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_open_search_hybrid_retriever.py +4 -1
  9. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/.gitignore +0 -0
  10. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/LICENSE +0 -0
  11. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/README.md +0 -0
  12. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/docker-compose.yml +0 -0
  13. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/pydoc/config_docusaurus.yml +0 -0
  14. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/pyproject.toml +0 -0
  15. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/__init__.py +0 -0
  16. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/bm25_retriever.py +0 -0
  17. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/embedding_retriever.py +0 -0
  18. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/metadata_retriever.py +0 -0
  19. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/open_search_hybrid_retriever.py +0 -0
  20. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/sql_retriever.py +0 -0
  21. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
  22. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/__init__.py +0 -0
  23. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/auth.py +0 -0
  24. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/filters.py +0 -0
  25. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/opensearch_scripts.py +0 -0
  26. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/py.typed +0 -0
  27. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/__init__.py +0 -0
  28. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/conftest.py +0 -0
  29. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_document_store_async.py +0 -0
  30. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_filters.py +0 -0
  31. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_metadata_retriever.py +0 -0
  32. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_metadata_retriever_async.py +0 -0
  33. {opensearch_haystack-6.5.1 → opensearch_haystack-7.0.0}/tests/test_sql_retriever.py +0 -0
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/opensearch-v6.5.1] - 2026-03-10
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - `OpenSearchDocumentStore` AsyncAWSAuth method signature changed (#2938)
8
+
9
+ ### 🧹 Chores
10
+
11
+ - Standardize author mentions (#2897)
12
+
13
+
3
14
  ## [integrations/opensearch-v6.5.0] - 2026-02-26
4
15
 
5
16
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opensearch-haystack
3
- Version: 6.5.1
3
+ Version: 7.0.0
4
4
  Summary: Haystack 2.x Document Store for OpenSearch
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/opensearch#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -82,7 +82,7 @@ class OpenSearchDocumentStore:
82
82
  mappings: dict[str, Any] | None = None,
83
83
  settings: dict[str, Any] | None = DEFAULT_SETTINGS,
84
84
  create_index: bool = True,
85
- http_auth: Any = (
85
+ http_auth: tuple[Secret, Secret] | tuple[str, str] | list[str] | str | AWSAuth | None = (
86
86
  Secret.from_env_var("OPENSEARCH_USERNAME", strict=False), # noqa: B008
87
87
  Secret.from_env_var("OPENSEARCH_PASSWORD", strict=False), # noqa: B008
88
88
  ),
@@ -138,17 +138,6 @@ class OpenSearchDocumentStore:
138
138
  self._mappings = mappings or self._get_default_mappings()
139
139
  self._settings = settings
140
140
  self._create_index = create_index
141
- self._http_auth_are_secrets = False
142
-
143
- # Handle authentication
144
- if isinstance(http_auth, (tuple, list)) and len(http_auth) == 2: # noqa: PLR2004
145
- username, password = http_auth
146
- if isinstance(username, Secret) and isinstance(password, Secret):
147
- self._http_auth_are_secrets = True
148
- username_val = username.resolve_value()
149
- password_val = password.resolve_value()
150
- http_auth = [username_val, password_val] if username_val and password_val else None
151
-
152
141
  self._http_auth = http_auth
153
142
  self._use_ssl = use_ssl
154
143
  self._verify_certs = verify_certs
@@ -218,17 +207,16 @@ class OpenSearchDocumentStore:
218
207
  Dictionary with serialized data.
219
208
  """
220
209
  # Handle http_auth serialization
221
- http_auth: list[dict[str, Any]] | dict[str, Any] | tuple[str, str] | list[str] | str = ""
222
- if isinstance(self._http_auth, list) and self._http_auth_are_secrets:
223
- # Recreate the Secret objects for serialization
224
- http_auth = [
225
- Secret.from_env_var("OPENSEARCH_USERNAME", strict=False).to_dict(),
226
- Secret.from_env_var("OPENSEARCH_PASSWORD", strict=False).to_dict(),
227
- ]
210
+ http_auth: list[dict[str, Any]] | dict[str, Any] | None = None
211
+ if (
212
+ isinstance(self._http_auth, (tuple, list))
213
+ and len(self._http_auth) == 2 # noqa: PLR2004
214
+ and isinstance(self._http_auth[0], Secret)
215
+ and isinstance(self._http_auth[1], Secret)
216
+ ):
217
+ http_auth = [self._http_auth[0].to_dict(), self._http_auth[1].to_dict()]
228
218
  elif isinstance(self._http_auth, AWSAuth):
229
219
  http_auth = self._http_auth.to_dict()
230
- else:
231
- http_auth = self._http_auth
232
220
 
233
221
  return default_to_dict(
234
222
  self,
@@ -267,12 +255,31 @@ class OpenSearchDocumentStore:
267
255
  init_params["http_auth"] = [Secret.from_dict(item) for item in http_auth] if are_secrets else http_auth
268
256
  return default_from_dict(cls, data)
269
257
 
258
+ def _resolve_http_auth(self) -> tuple[str, str] | list[str] | str | AWSAuth | None:
259
+ """Resolves Secret objects in http_auth to their plain values."""
260
+ if isinstance(self._http_auth, (tuple, list)) and len(self._http_auth) == 2: # noqa: PLR2004
261
+ first, second = self._http_auth
262
+ if isinstance(first, Secret) and isinstance(second, Secret):
263
+ username = first.resolve_value()
264
+ password = second.resolve_value()
265
+ if username and password:
266
+ return [username, password]
267
+ if not username and not password:
268
+ return None
269
+ msg = "http_auth requires both username and password to be set, but only one was provided."
270
+ raise DocumentStoreError(msg)
271
+ if isinstance(first, str) and isinstance(second, str):
272
+ return (first, second)
273
+ if isinstance(self._http_auth, (str, AWSAuth)):
274
+ return self._http_auth
275
+ return None
276
+
270
277
  def _ensure_initialized(self):
271
278
  # Ideally, we have a warm-up stage for document stores as well as components.
272
279
  if not self._client:
273
280
  self._client = OpenSearch(
274
281
  hosts=self._hosts,
275
- http_auth=self._http_auth,
282
+ http_auth=self._resolve_http_auth(),
276
283
  use_ssl=self._use_ssl,
277
284
  verify_certs=self._verify_certs,
278
285
  timeout=self._timeout,
@@ -284,7 +291,8 @@ class OpenSearchDocumentStore:
284
291
 
285
292
  async def _ensure_initialized_async(self):
286
293
  if not self._async_client:
287
- async_http_auth = AsyncAWSAuth(self._http_auth) if isinstance(self._http_auth, AWSAuth) else self._http_auth
294
+ resolved_auth = self._resolve_http_auth()
295
+ async_http_auth = AsyncAWSAuth(resolved_auth) if isinstance(resolved_auth, AWSAuth) else resolved_auth
288
296
  self._async_client = AsyncOpenSearch(
289
297
  hosts=self._hosts,
290
298
  http_auth=async_http_auth,
@@ -254,7 +254,7 @@ class TestDocumentStoreWithAuth:
254
254
  document_store._ensure_initialized()
255
255
  assert document_store._client
256
256
  _mock_opensearch_client.assert_called_once()
257
- assert _mock_opensearch_client.call_args[1]["http_auth"] == ["user", "pw"]
257
+ assert _mock_opensearch_client.call_args[1]["http_auth"] == ("user", "pw")
258
258
 
259
259
  @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
260
260
  def test_ds_from_dict_aws_auth(self, _mock_opensearch_client, monkeypatch: pytest.MonkeyPatch):
@@ -304,7 +304,7 @@ class TestDocumentStoreWithAuth:
304
304
  "settings": {"index.knn": True},
305
305
  "return_embedding": False,
306
306
  "create_index": True,
307
- "http_auth": ("user", "pw"),
307
+ "http_auth": None,
308
308
  "use_ssl": None,
309
309
  "verify_certs": None,
310
310
  "timeout": None,
@@ -56,7 +56,10 @@ def test_to_dict(_mock_opensearch_client):
56
56
  "settings": {"index.knn": True},
57
57
  "return_embedding": False,
58
58
  "create_index": True,
59
- "http_auth": None,
59
+ "http_auth": [
60
+ {"type": "env_var", "env_vars": ["OPENSEARCH_USERNAME"], "strict": False},
61
+ {"type": "env_var", "env_vars": ["OPENSEARCH_PASSWORD"], "strict": False},
62
+ ],
60
63
  "use_ssl": None,
61
64
  "verify_certs": None,
62
65
  "timeout": None,
@@ -38,7 +38,10 @@ def test_to_dict(_mock_opensearch_client):
38
38
  "settings": {"index.knn": True},
39
39
  "return_embedding": False,
40
40
  "create_index": True,
41
- "http_auth": None,
41
+ "http_auth": [
42
+ {"type": "env_var", "env_vars": ["OPENSEARCH_USERNAME"], "strict": False},
43
+ {"type": "env_var", "env_vars": ["OPENSEARCH_PASSWORD"], "strict": False},
44
+ ],
42
45
  "use_ssl": None,
43
46
  "verify_certs": None,
44
47
  "timeout": None,
@@ -46,6 +49,16 @@ def test_to_dict(_mock_opensearch_client):
46
49
  }
47
50
 
48
51
 
52
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
53
+ def test_to_dict_with_http_auth_str(_mock_opensearch_client):
54
+ """
55
+ Verify that plain strings secrets are not serialized.
56
+ """
57
+ document_store = OpenSearchDocumentStore(hosts="some hosts", http_auth=("admin", "admin"))
58
+ res = document_store.to_dict()
59
+ assert res["init_parameters"]["http_auth"] is None
60
+
61
+
49
62
  @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
50
63
  def test_from_dict(_mock_opensearch_client):
51
64
  data = {
@@ -93,6 +106,54 @@ def test_from_dict(_mock_opensearch_client):
93
106
  assert document_store._timeout == 60
94
107
 
95
108
 
109
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
110
+ def test_from_dict_with_http_auth_str(_mock_opensearch_client):
111
+ """
112
+ Verify that serialized plain strings secrets can be properly deserialized.
113
+ """
114
+ data = {
115
+ "type": "haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore",
116
+ "init_parameters": {
117
+ "hosts": "some hosts",
118
+ "index": "default",
119
+ "http_auth": ("admin", "admin"),
120
+ },
121
+ }
122
+ document_store = OpenSearchDocumentStore.from_dict(data)
123
+ assert document_store._http_auth == ("admin", "admin")
124
+
125
+
126
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
127
+ def test_resolve_http_auth_with_secrets(_mock_opensearch_client, monkeypatch):
128
+ monkeypatch.setenv("OPENSEARCH_USERNAME", "admin")
129
+ monkeypatch.setenv("OPENSEARCH_PASSWORD", "secret")
130
+ store = OpenSearchDocumentStore(hosts="testhost")
131
+ assert store._resolve_http_auth() == ["admin", "secret"]
132
+
133
+
134
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
135
+ def test_resolve_http_auth_with_no_secrets(_mock_opensearch_client, monkeypatch):
136
+ monkeypatch.delenv("OPENSEARCH_USERNAME", raising=False)
137
+ monkeypatch.delenv("OPENSEARCH_PASSWORD", raising=False)
138
+ store = OpenSearchDocumentStore(hosts="testhost")
139
+ assert store._resolve_http_auth() is None
140
+
141
+
142
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
143
+ def test_resolve_http_auth_with_partial_secrets(_mock_opensearch_client, monkeypatch):
144
+ monkeypatch.setenv("OPENSEARCH_USERNAME", "admin")
145
+ monkeypatch.delenv("OPENSEARCH_PASSWORD", raising=False)
146
+ store = OpenSearchDocumentStore(hosts="testhost")
147
+ with pytest.raises(DocumentStoreError, match="http_auth requires both username and password"):
148
+ store._resolve_http_auth()
149
+
150
+
151
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
152
+ def test_resolve_http_auth_with_plain_strings(_mock_opensearch_client):
153
+ store = OpenSearchDocumentStore(hosts="testhost", http_auth=("admin", "admin"))
154
+ assert store._resolve_http_auth() == ("admin", "admin")
155
+
156
+
96
157
  @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
97
158
  def test_init_is_lazy(_mock_opensearch_client):
98
159
  OpenSearchDocumentStore(hosts="testhost")
@@ -110,16 +171,19 @@ def test_get_default_mappings(_mock_opensearch_client):
110
171
  }
111
172
 
112
173
 
174
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
113
175
  @patch("haystack_integrations.document_stores.opensearch.document_store.bulk")
114
- def test_routing_extracted_from_metadata(mock_bulk, document_store):
176
+ def test_routing_extracted_from_metadata(mock_bulk, _mock_opensearch_client):
115
177
  """Test routing extraction from document metadata"""
116
178
  mock_bulk.return_value = (2, [])
117
179
 
180
+ store = OpenSearchDocumentStore(hosts="testhost", http_auth=("admin", "admin"))
181
+
118
182
  docs = [
119
183
  Document(id="1", content="Doc", meta={"_routing": "user_a", "other": "data"}),
120
184
  Document(id="2", content="Doc"),
121
185
  ]
122
- document_store.write_documents(docs)
186
+ store.write_documents(docs)
123
187
 
124
188
  actions = list(mock_bulk.call_args.kwargs["actions"])
125
189
 
@@ -135,13 +199,16 @@ def test_routing_extracted_from_metadata(mock_bulk, document_store):
135
199
  assert "_routing" not in actions[1]["_source"].get("meta", {})
136
200
 
137
201
 
202
+ @patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
138
203
  @patch("haystack_integrations.document_stores.opensearch.document_store.bulk")
139
- def test_routing_in_delete(mock_bulk, document_store):
204
+ def test_routing_in_delete(mock_bulk, _mock_opensearch_client):
140
205
  """Test routing parameter in delete operations"""
141
206
  mock_bulk.return_value = (2, [])
142
207
 
208
+ store = OpenSearchDocumentStore(hosts="testhost", http_auth=("admin", "admin"))
209
+
143
210
  routing_map = {"1": "user_a", "2": "user_b"}
144
- document_store.delete_documents(["1", "2", "3"], routing=routing_map)
211
+ store.delete_documents(["1", "2", "3"], routing=routing_map)
145
212
 
146
213
  actions = list(mock_bulk.call_args.kwargs["actions"])
147
214
 
@@ -72,7 +72,10 @@ def test_to_dict(_mock_opensearch_client):
72
72
  },
73
73
  "return_embedding": False,
74
74
  "create_index": True,
75
- "http_auth": None,
75
+ "http_auth": [
76
+ {"type": "env_var", "env_vars": ["OPENSEARCH_USERNAME"], "strict": False},
77
+ {"type": "env_var", "env_vars": ["OPENSEARCH_PASSWORD"], "strict": False},
78
+ ],
76
79
  "use_ssl": None,
77
80
  "verify_certs": None,
78
81
  "timeout": None,
@@ -46,7 +46,10 @@ class TestOpenSearchHybridRetriever:
46
46
  "settings": {"index.knn": True},
47
47
  "create_index": True,
48
48
  "return_embedding": False,
49
- "http_auth": None,
49
+ "http_auth": [
50
+ {"type": "env_var", "env_vars": ["OPENSEARCH_USERNAME"], "strict": False},
51
+ {"type": "env_var", "env_vars": ["OPENSEARCH_PASSWORD"], "strict": False},
52
+ ],
50
53
  "use_ssl": None,
51
54
  "verify_certs": None,
52
55
  "timeout": None,