Repository: deepset-ai/haystack

Issue:
Initialising an OpenSearchDocumentStore results in an error
Hey team, I'm getting an error which I didn't used to using the OpenSearchDocumentStore before when initialising it:

```
from haystack.document_stores import OpenSearchDocumentStore
from haystack.utils import fetch_archive_from_http, clean_wiki_text, convert_files_to_docs

document_store = OpenSearchDocumentStore(port=9201)

doc_dir = "data/article_txt_got"
s3_url = "https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/documents/wiki_gameofthrones_txt.zip"
fetch_archive_from_http(url=s3_url, output_dir=doc_dir)

dicts = convert_files_to_docs(dir_path=doc_dir, clean_func=clean_wiki_text, split_paragraphs=True)

document_store.write_documents(dicts)
```

Error: `'OpenSearchDocumentStore' object has no attribute 'space_type_to_similarity'`



Discussion:
My first guess is that the problem has to do with https://github.com/deepset-ai/haystack/pull/2362/files @ZanSara could you please check that?
Yes, I think the problem is that before that PR 
`self.space_type_to_similarity = {v: k for k, v in self.similarity_to_space_type.items()}` was executed first and then `super.__init__` was executed after that. Now,  `super().__init__()` is executed before `self.space_type_to_similarity` is set. So we need to reverse the order.

Resolving patch:
diff --git a/haystack/document_stores/elasticsearch.py b/haystack/document_stores/elasticsearch.py
--- a/haystack/document_stores/elasticsearch.py
+++ b/haystack/document_stores/elasticsearch.py
@@ -1724,6 +1724,9 @@ def __init__(
                              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 @@ def __init__(
             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,


Test patch:
diff --git a/test/test_document_store.py b/test/test_document_store.py
--- a/test/test_document_store.py
+++ b/test/test_document_store.py
@@ -20,7 +20,12 @@
     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"