Harrison/opensearch logic (#3631)

Co-authored-by: engineer-matsuo <95115586+engineer-matsuo@users.noreply.github.com>
This commit is contained in:
Harrison Chase
2023-04-26 22:08:03 -07:00
committed by GitHub
parent cf384dcb7f
commit ab749fa1bb
2 changed files with 62 additions and 3 deletions

View File

@@ -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")]