opensearch-haystack 6.5.0__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.
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/CHANGELOG.md +30 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/PKG-INFO +2 -2
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/pyproject.toml +1 -1
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/auth.py +23 -7
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/document_store.py +31 -23
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_auth.py +56 -5
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_bm25_retriever.py +4 -1
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_document_store.py +72 -5
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_embedding_retriever.py +4 -1
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_open_search_hybrid_retriever.py +4 -1
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/.gitignore +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/LICENSE +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/README.md +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/docker-compose.yml +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/pydoc/config_docusaurus.yml +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/__init__.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/bm25_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/embedding_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/metadata_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/open_search_hybrid_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/opensearch/sql_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/__init__.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/filters.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/opensearch/opensearch_scripts.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/__init__.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/conftest.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_document_store_async.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_filters.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_metadata_retriever.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_metadata_retriever_async.py +0 -0
- {opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_sql_retriever.py +0 -0
|
@@ -1,5 +1,35 @@
|
|
|
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
|
+
|
|
14
|
+
## [integrations/opensearch-v6.5.0] - 2026-02-26
|
|
15
|
+
|
|
16
|
+
### 🐛 Bug Fixes
|
|
17
|
+
|
|
18
|
+
- OpenSearch-3.x SQL stopped supporting DSL-format SQL JSON (#2876)
|
|
19
|
+
|
|
20
|
+
### 📚 Documentation
|
|
21
|
+
|
|
22
|
+
- Simplify pydoc configs (#2855)
|
|
23
|
+
|
|
24
|
+
### 🧪 Testing
|
|
25
|
+
|
|
26
|
+
- Replacing each `DocumentStore` specific tests and used the generalised ones from `haystack.testing.document_store` (#2812)
|
|
27
|
+
|
|
28
|
+
### 🧹 Chores
|
|
29
|
+
|
|
30
|
+
- Remove unused allow-direct-references (#2866)
|
|
31
|
+
|
|
32
|
+
|
|
3
33
|
## [integrations/opensearch-v6.4.0] - 2026-02-11
|
|
4
34
|
|
|
5
35
|
### 🚀 Features
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opensearch-haystack
|
|
3
|
-
Version:
|
|
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
|
|
7
7
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/opensearch
|
|
8
|
-
Author-email: deepset <info@deepset.ai>
|
|
8
|
+
Author-email: deepset GmbH <info@deepset.ai>
|
|
9
9
|
License-Expression: Apache-2.0
|
|
10
10
|
License-File: LICENSE
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
@@ -10,7 +10,7 @@ readme = "README.md"
|
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
keywords = []
|
|
13
|
-
authors = [{ name = "deepset", email = "info@deepset.ai" }]
|
|
13
|
+
authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"License :: OSI Approved :: Apache Software License",
|
|
16
16
|
"Development Status :: 4 - Beta",
|
|
@@ -125,19 +125,27 @@ class AWSAuth:
|
|
|
125
125
|
)
|
|
126
126
|
return default_from_dict(cls, data)
|
|
127
127
|
|
|
128
|
-
def __call__(
|
|
128
|
+
def __call__(
|
|
129
|
+
self,
|
|
130
|
+
method: str,
|
|
131
|
+
url: str,
|
|
132
|
+
body: Any = None,
|
|
133
|
+
headers: dict[str, str] | None = None,
|
|
134
|
+
) -> dict[str, str]:
|
|
129
135
|
"""
|
|
130
136
|
Signs the request and returns headers.
|
|
131
137
|
|
|
132
138
|
This method is executed by Urllib3 when making a request to the OpenSearch service.
|
|
139
|
+
Compatible with opensearch-py 3.x which may call with (method, url, body, headers).
|
|
133
140
|
|
|
134
141
|
:param method: HTTP method
|
|
135
142
|
:param url: URL
|
|
136
|
-
:param body:
|
|
143
|
+
:param body: Request body
|
|
144
|
+
:param headers: Request headers to sign (opensearch-py 3.x passes these)
|
|
137
145
|
:return:
|
|
138
146
|
A dictionary containing the signed headers.
|
|
139
147
|
"""
|
|
140
|
-
return self._urllib3_aws_v4_signer_auth(method, url, body)
|
|
148
|
+
return self._urllib3_aws_v4_signer_auth(method, url, body, headers)
|
|
141
149
|
|
|
142
150
|
def _get_aws_v4_signer_auth(self, signer_auth_class: type[TSignerAuth]) -> TSignerAuth:
|
|
143
151
|
try:
|
|
@@ -184,17 +192,25 @@ class AsyncAWSAuth:
|
|
|
184
192
|
self.aws_auth = aws_auth
|
|
185
193
|
self._async_aws_v4_signer_auth = self.aws_auth._get_aws_v4_signer_auth(AWSV4SignerAsyncAuth)
|
|
186
194
|
|
|
187
|
-
def __call__(
|
|
195
|
+
def __call__(
|
|
196
|
+
self,
|
|
197
|
+
method: str,
|
|
198
|
+
url: str,
|
|
199
|
+
body: Any = None,
|
|
200
|
+
headers: dict[str, str] | None = None,
|
|
201
|
+
) -> dict[str, str]:
|
|
188
202
|
"""
|
|
189
203
|
Signs the request and returns headers.
|
|
190
204
|
|
|
191
205
|
This method is executed by AsyncHttpConnection when making a request to the OpenSearch service.
|
|
206
|
+
Compatible with opensearch-py 3.x which calls with (method, url, body, headers).
|
|
207
|
+
The query_string parameter was removed in opensearch-py 3.x.
|
|
192
208
|
|
|
193
209
|
:param method: HTTP method
|
|
194
210
|
:param url: URL
|
|
195
|
-
:param
|
|
196
|
-
:param
|
|
211
|
+
:param body: Request body
|
|
212
|
+
:param headers: Request headers to sign (opensearch-py 3.x passes these)
|
|
197
213
|
:return:
|
|
198
214
|
A dictionary containing the signed headers.
|
|
199
215
|
"""
|
|
200
|
-
return self._async_aws_v4_signer_auth(method, url,
|
|
216
|
+
return self._async_aws_v4_signer_auth(method, url, body, headers)
|
|
@@ -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:
|
|
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] |
|
|
222
|
-
if
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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.
|
|
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
|
-
|
|
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,
|
|
@@ -120,15 +120,16 @@ class TestAWSAuth:
|
|
|
120
120
|
_get_aws_v4_signer_auth.return_value = signer_auth_mock
|
|
121
121
|
aws_auth = AWSAuth()
|
|
122
122
|
aws_auth(method="GET", url="http://some.url", body="some body")
|
|
123
|
-
signer_auth_mock.assert_called_once_with("GET", "http://some.url", "some body")
|
|
123
|
+
signer_auth_mock.assert_called_once_with("GET", "http://some.url", "some body", None)
|
|
124
124
|
|
|
125
125
|
@patch("haystack_integrations.document_stores.opensearch.auth.AWSAuth._get_aws_v4_signer_auth")
|
|
126
126
|
def test_call_async(self, _get_aws_v4_signer_auth):
|
|
127
|
+
"""AsyncAWSAuth must accept (method, url, body, headers) as per opensearch-py 3.x API."""
|
|
127
128
|
signer_auth_mock = Mock()
|
|
128
129
|
_get_aws_v4_signer_auth.return_value = signer_auth_mock
|
|
129
130
|
async_aws_auth = AsyncAWSAuth(AWSAuth())
|
|
130
|
-
async_aws_auth(method="GET", url="http://some.url",
|
|
131
|
-
signer_auth_mock.assert_called_once_with("GET", "http://some.url", "", "
|
|
131
|
+
async_aws_auth(method="GET", url="http://some.url", body="some body", headers={"Host": "localhost"})
|
|
132
|
+
signer_auth_mock.assert_called_once_with("GET", "http://some.url", "some body", {"Host": "localhost"})
|
|
132
133
|
|
|
133
134
|
def test_async_aws_auth_init(self):
|
|
134
135
|
data = {
|
|
@@ -150,6 +151,56 @@ class TestAWSAuth:
|
|
|
150
151
|
assert isinstance(async_aws_auth._async_aws_v4_signer_auth, AWSV4SignerAsyncAuth)
|
|
151
152
|
|
|
152
153
|
|
|
154
|
+
class TestAWSAuthRealSigning:
|
|
155
|
+
"""
|
|
156
|
+
Tests that use real boto3.Session and real signing (no mocks on Session or signer).
|
|
157
|
+
|
|
158
|
+
Verifies both AWSAuth and AsyncAWSAuth produce valid SigV4 headers when called
|
|
159
|
+
with (method, url, body, headers) as opensearch-py 3.x does.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
def test_sync_auth_real_signing_no_network(self, monkeypatch):
|
|
163
|
+
monkeypatch.setenv("AWS_EC2_METADATA_DISABLED", "true")
|
|
164
|
+
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "AKIDEXAMPLE")
|
|
165
|
+
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
|
|
166
|
+
monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1")
|
|
167
|
+
|
|
168
|
+
aws_auth = AWSAuth()
|
|
169
|
+
|
|
170
|
+
signed_headers = aws_auth(
|
|
171
|
+
method="GET",
|
|
172
|
+
url="https://example.com/_search?q=test",
|
|
173
|
+
body=b"",
|
|
174
|
+
headers={"Host": "example.com"},
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
assert "Authorization" in signed_headers
|
|
178
|
+
assert signed_headers["Authorization"].startswith("AWS4-HMAC-SHA256 ")
|
|
179
|
+
assert "X-Amz-Date" in signed_headers
|
|
180
|
+
assert "X-Amz-Content-SHA256" in signed_headers
|
|
181
|
+
|
|
182
|
+
def test_async_auth_real_signing_no_network(self, monkeypatch):
|
|
183
|
+
monkeypatch.setenv("AWS_EC2_METADATA_DISABLED", "true")
|
|
184
|
+
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "AKIDEXAMPLE")
|
|
185
|
+
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
|
|
186
|
+
monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1")
|
|
187
|
+
|
|
188
|
+
aws_auth = AWSAuth()
|
|
189
|
+
async_aws_auth = AsyncAWSAuth(aws_auth)
|
|
190
|
+
|
|
191
|
+
signed_headers = async_aws_auth(
|
|
192
|
+
method="GET",
|
|
193
|
+
url="https://example.com/_search?q=test",
|
|
194
|
+
body=b"",
|
|
195
|
+
headers={"Host": "example.com"},
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
assert "Authorization" in signed_headers
|
|
199
|
+
assert signed_headers["Authorization"].startswith("AWS4-HMAC-SHA256 ")
|
|
200
|
+
assert "X-Amz-Date" in signed_headers
|
|
201
|
+
assert "X-Amz-Content-SHA256" in signed_headers
|
|
202
|
+
|
|
203
|
+
|
|
153
204
|
class TestDocumentStoreWithAuth:
|
|
154
205
|
@pytest.fixture(autouse=True)
|
|
155
206
|
def mock_boto3_session(self):
|
|
@@ -203,7 +254,7 @@ class TestDocumentStoreWithAuth:
|
|
|
203
254
|
document_store._ensure_initialized()
|
|
204
255
|
assert document_store._client
|
|
205
256
|
_mock_opensearch_client.assert_called_once()
|
|
206
|
-
assert _mock_opensearch_client.call_args[1]["http_auth"] ==
|
|
257
|
+
assert _mock_opensearch_client.call_args[1]["http_auth"] == ("user", "pw")
|
|
207
258
|
|
|
208
259
|
@patch("haystack_integrations.document_stores.opensearch.document_store.OpenSearch")
|
|
209
260
|
def test_ds_from_dict_aws_auth(self, _mock_opensearch_client, monkeypatch: pytest.MonkeyPatch):
|
|
@@ -253,7 +304,7 @@ class TestDocumentStoreWithAuth:
|
|
|
253
304
|
"settings": {"index.knn": True},
|
|
254
305
|
"return_embedding": False,
|
|
255
306
|
"create_index": True,
|
|
256
|
-
"http_auth":
|
|
307
|
+
"http_auth": None,
|
|
257
308
|
"use_ssl": None,
|
|
258
309
|
"verify_certs": None,
|
|
259
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":
|
|
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":
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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":
|
|
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,
|
{opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_open_search_hybrid_retriever.py
RENAMED
|
@@ -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":
|
|
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,
|
|
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
|
{opensearch_haystack-6.5.0 → opensearch_haystack-7.0.0}/tests/test_metadata_retriever_async.py
RENAMED
|
File without changes
|
|
File without changes
|