remove deprecated OpenDistroElasticsearchDocumentStore (#4361)

This commit is contained in:
Massimiliano Pippi 2023-03-14 09:12:49 +01:00 committed by GitHub
parent 7d17ca7391
commit 5aa19ffde6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 105 deletions

View File

@ -14,9 +14,6 @@ from haystack.document_stores.es_converter import (
)
OpenSearchDocumentStore = safe_import("haystack.document_stores.opensearch", "OpenSearchDocumentStore", "opensearch")
OpenDistroElasticsearchDocumentStore = safe_import(
"haystack.document_stores.opensearch", "OpenDistroElasticsearchDocumentStore", "opensearch"
)
SQLDocumentStore = safe_import("haystack.document_stores.sql", "SQLDocumentStore", "sql")
FAISSDocumentStore = safe_import("haystack.document_stores.faiss", "FAISSDocumentStore", "faiss")
PineconeDocumentStore = safe_import("haystack.document_stores.pinecone", "PineconeDocumentStore", "pinecone")

View File

@ -1339,86 +1339,3 @@ class OpenSearchDocumentStore(SearchEngineDocumentStore):
progress_bar.update(batch_size)
finally:
opensearch_logger.setLevel(original_log_level)
class OpenDistroElasticsearchDocumentStore(OpenSearchDocumentStore):
"""
A DocumentStore which has an Open Distro for Elasticsearch service behind it.
"""
def __init__(
self,
scheme: str = "https",
username: str = "admin",
password: str = "admin",
host: Union[str, List[str]] = "localhost",
port: Union[int, List[int]] = 9200,
api_key_id: Optional[str] = None,
api_key: Optional[str] = None,
aws4auth=None,
index: str = "document",
label_index: str = "label",
search_fields: Union[str, list] = "content",
content_field: str = "content",
name_field: str = "name",
embedding_field: str = "embedding",
embedding_dim: int = 768,
custom_mapping: Optional[dict] = None,
excluded_meta_data: Optional[list] = None,
analyzer: str = "standard",
ca_certs: Optional[str] = None,
verify_certs: bool = False,
recreate_index: bool = False,
create_index: bool = True,
refresh_type: str = "wait_for",
similarity: str = "cosine", # Mind this different default param
timeout: int = 30,
return_embedding: bool = False,
duplicate_documents: str = "overwrite",
index_type: str = "flat",
scroll: str = "1d",
skip_missing_embeddings: bool = True,
synonyms: Optional[List] = None,
synonym_type: str = "synonym",
use_system_proxy: bool = False,
):
logger.warning(
"Open Distro for Elasticsearch has been replaced by OpenSearch! "
"See https://opensearch.org/faq/ for details. "
"We recommend using the OpenSearchDocumentStore instead."
)
super().__init__(
scheme=scheme,
username=username,
password=password,
host=host,
port=port,
api_key_id=api_key_id,
api_key=api_key,
aws4auth=aws4auth,
index=index,
label_index=label_index,
search_fields=search_fields,
content_field=content_field,
name_field=name_field,
embedding_field=embedding_field,
embedding_dim=embedding_dim,
custom_mapping=custom_mapping,
excluded_meta_data=excluded_meta_data,
analyzer=analyzer,
ca_certs=ca_certs,
verify_certs=verify_certs,
recreate_index=recreate_index,
create_index=create_index,
refresh_type=refresh_type,
similarity=similarity,
timeout=timeout,
return_embedding=return_embedding,
duplicate_documents=duplicate_documents,
index_type=index_type,
scroll=scroll,
skip_missing_embeddings=skip_missing_embeddings,
synonyms=synonyms,
synonym_type=synonym_type,
use_system_proxy=use_system_proxy,
)

View File

@ -27,7 +27,7 @@ class BM25Retriever(BaseRetriever):
scale_score: bool = True,
):
"""
:param document_store: An instance of one of the following DocumentStores to retrieve from: InMemoryDocumentStore, ElasticsearchDocumentStore, OpenSearchDocumentStore, and OpenDistroElasticsearchDocumentStore.
:param document_store: An instance of one of the following DocumentStores to retrieve from: InMemoryDocumentStore, ElasticsearchDocumentStore and OpenSearchDocumentStore.
If None, a document store must be passed to the retrieve method for this Retriever to work.
:param all_terms_must_match: Whether all terms of the query must match the document.
If true all query terms must be present in a document in order to be retrieved (i.e the AND operator is being used implicitly between query terms: "cozy fish restaurant" -> "cozy AND fish AND restaurant").

View File

@ -11,7 +11,6 @@ import opensearchpy
from haystack.document_stores.opensearch import (
OpenSearch,
OpenSearchDocumentStore,
OpenDistroElasticsearchDocumentStore,
RequestsHttpConnection,
Urllib3HttpConnection,
RequestError,
@ -1240,20 +1239,3 @@ class TestOpenSearchDocumentStore(DocumentStoreBaseTestAbstract, SearchEngineDoc
]
mocked_document_store._bulk(documents=docs_to_write, _timeout=0, _remaining_tries=3)
assert mocked_bulk.call_count == 5
class TestOpenDistroElasticsearchDocumentStore:
@pytest.mark.unit
def test_deprecation_notice(self, monkeypatch, caplog):
klass = OpenDistroElasticsearchDocumentStore
monkeypatch.setattr(klass, "_init_client", MagicMock())
monkeypatch.setattr(klass, "_validate_and_adjust_document_index", MagicMock())
with caplog.at_level(logging.WARN, logger="haystack.document_stores.opensearch"):
klass()
assert caplog.record_tuples == [
(
"haystack.document_stores.opensearch",
logging.WARN,
"Open Distro for Elasticsearch has been replaced by OpenSearch! See https://opensearch.org/faq/ for details. We recommend using the OpenSearchDocumentStore instead.",
)
]