diff --git a/.github/workflows/linux_ci.yml b/.github/workflows/linux_ci.yml index 72eb0ec56..3b08f71ce 100644 --- a/.github/workflows/linux_ci.yml +++ b/.github/workflows/linux_ci.yml @@ -259,6 +259,9 @@ jobs: - name: Run Elasticsearch run: docker run -d -p 9200:9200 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms128m -Xmx128m" elasticsearch:7.9.2 + - name: Run Opensearch + run: docker run -d -p 9201:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:1.2.4 + - name: Run Milvus run: | cd ../../ # Avoid causing permission issues on hashFiles later by creating unreadable folders like "volumes" diff --git a/haystack/document_stores/elasticsearch.py b/haystack/document_stores/elasticsearch.py index ca13401da..34cec2e5c 100644 --- a/haystack/document_stores/elasticsearch.py +++ b/haystack/document_stores/elasticsearch.py @@ -1724,6 +1724,9 @@ class OpenSearchDocumentStore(ElasticsearchDocumentStore): Synonym or Synonym_graph to handle synonyms, including multi-word synonyms correctly during the analysis process. More info at https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-graph-tokenfilter.html """ + self.embeddings_field_supports_similarity = False + self.similarity_to_space_type = {"cosine": "cosinesimil", "dot_product": "innerproduct", "l2": "l2"} + self.space_type_to_similarity = {v: k for k, v in self.similarity_to_space_type.items()} super().__init__( scheme=scheme, username=username, @@ -1759,9 +1762,6 @@ class OpenSearchDocumentStore(ElasticsearchDocumentStore): synonym_type=synonym_type, use_system_proxy=use_system_proxy, ) - self.embeddings_field_supports_similarity = False - self.similarity_to_space_type = {"cosine": "cosinesimil", "dot_product": "innerproduct", "l2": "l2"} - self.space_type_to_similarity = {v: k for k, v in self.similarity_to_space_type.items()} def query_by_embedding( self, diff --git a/test/test_document_store.py b/test/test_document_store.py index 6386e3e19..9695dda6d 100644 --- a/test/test_document_store.py +++ b/test/test_document_store.py @@ -20,7 +20,12 @@ from .conftest import ( DC_TEST_INDEX, SAMPLES_PATH, ) -from haystack.document_stores import WeaviateDocumentStore, DeepsetCloudDocumentStore, InMemoryDocumentStore +from haystack.document_stores import ( + OpenSearchDocumentStore, + WeaviateDocumentStore, + DeepsetCloudDocumentStore, + InMemoryDocumentStore, +) from haystack.document_stores.base import BaseDocumentStore from haystack.document_stores.es_converter import elasticsearch_index_to_document_store from haystack.errors import DuplicateDocumentError @@ -89,6 +94,11 @@ def test_init_elastic_client(): _ = ElasticsearchDocumentStore(host=["localhost"], port=[9200], api_key="test", api_key_id="test") +@pytest.mark.elasticsearch +def test_init_opensearch_client(): + OpenSearchDocumentStore(index="test_index", port=9201) + + @pytest.mark.elasticsearch def test_init_elastic_doc_store_with_index_recreation(): index_name = "test_index_recreation"