mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-25 04:49:17 +00:00
Add the usage of SSL certificates for Elasticsearch and user password authentication (#5058)
Enhance the code to support SSL authentication for Elasticsearch when using the VectorStore module, as previous versions did not provide this capability. @dev2049 --------- Co-authored-by: caidong <zhucaidong1992@gmail.com> Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This commit is contained in:
@@ -48,6 +48,23 @@ class TestElasticsearch:
|
||||
output = docsearch.similarity_search("foo", k=1)
|
||||
assert output == [Document(page_content="foo")]
|
||||
|
||||
def test_similarity_search_with_ssl_verify(self, elasticsearch_url: str) -> None:
|
||||
"""Test end to end construction and search with ssl verify."""
|
||||
ssl_verify = {
|
||||
"verify_certs": True,
|
||||
"basic_auth": ("ES_USER", "ES_PASSWORD"),
|
||||
"ca_certs": "ES_CA_CERTS_PATH",
|
||||
}
|
||||
texts = ["foo", "bar", "baz"]
|
||||
docsearch = ElasticVectorSearch.from_texts(
|
||||
texts,
|
||||
FakeEmbeddings(),
|
||||
elasticsearch_url=elasticsearch_url,
|
||||
ssl_verify=ssl_verify,
|
||||
)
|
||||
output = docsearch.similarity_search("foo", k=1)
|
||||
assert output == [Document(page_content="foo")]
|
||||
|
||||
def test_similarity_search_with_metadata(self, elasticsearch_url: str) -> None:
|
||||
"""Test end to end construction and search with metadata."""
|
||||
texts = ["foo", "bar", "baz"]
|
||||
|
Reference in New Issue
Block a user