mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-12 00:11:17 +00:00
Harrison/opensearch logic (#3631)
Co-authored-by: engineer-matsuo <95115586+engineer-matsuo@users.noreply.github.com>
This commit is contained in:
@@ -174,3 +174,26 @@ def test_appx_search_with_lucene_filter() -> None:
|
||||
)
|
||||
output = docsearch.similarity_search("foo", k=3, lucene_filter=lucene_filter_val)
|
||||
assert output == [Document(page_content="bar")]
|
||||
|
||||
|
||||
def test_opensearch_with_custom_field_name_appx_true() -> None:
|
||||
"""Test Approximate Search with custom field name appx true."""
|
||||
text_input = ["test", "add", "text", "method"]
|
||||
docsearch = OpenSearchVectorSearch.from_texts(
|
||||
text_input,
|
||||
FakeEmbeddings(),
|
||||
opensearch_url=DEFAULT_OPENSEARCH_URL,
|
||||
is_appx_search=True,
|
||||
)
|
||||
output = docsearch.similarity_search("add", k=1)
|
||||
assert output == [Document(page_content="add")]
|
||||
|
||||
|
||||
def test_opensearch_with_custom_field_name_appx_false() -> None:
|
||||
"""Test Approximate Search with custom field name appx true."""
|
||||
text_input = ["test", "add", "text", "method"]
|
||||
docsearch = OpenSearchVectorSearch.from_texts(
|
||||
text_input, FakeEmbeddings(), opensearch_url=DEFAULT_OPENSEARCH_URL
|
||||
)
|
||||
output = docsearch.similarity_search("add", k=1)
|
||||
assert output == [Document(page_content="add")]
|
||||
|
Reference in New Issue
Block a user