Repository: deepset-ai/haystack

Issue:
MostSimilarDocumentsPipeline doesn't have pipeline property
**Describe the bug**
MostSimilarDocumentsPipeline, unlike all other pipelines, doesn't have the underlying pipeline property/field. As a consequence, any method from the superclass that replies on pipeline (get_type, save_to_yaml) will fail.

**Expected behavior**
Just like any other pipeline e.g. SearchSummarizationPipeline, ExtractiveQAPipeline etc., the above-mentioned methods should be supported.

**To Reproduce**
Create MostSimilarDocumentsPipeline and invoke the above-mentioned methods.

**FAQ Check**
- [x] Have you had a look at [our new FAQ page](https://haystack.deepset.ai/overview/faq)?



Discussion:

Resolving patch:
diff --git a/haystack/pipelines/standard_pipelines.py b/haystack/pipelines/standard_pipelines.py
--- a/haystack/pipelines/standard_pipelines.py
+++ b/haystack/pipelines/standard_pipelines.py
@@ -706,6 +706,12 @@ def __init__(self, document_store: BaseDocumentStore):
 
         :param document_store: Document Store instance with already stored embeddings.
         """
+        # we create a pipeline and add the document store as a node
+        # however, we do not want to use the document store's run method,
+        # but rather the query_by_embedding method
+        # pipeline property is here so the superclass methods that rely on pipeline property work
+        self.pipeline = Pipeline()
+        self.pipeline.add_node(component=document_store, name="DocumentStore", inputs=["Query"])
         self.document_store = document_store
 
     def run(self, document_ids: List[str], top_k: int = 5):


Test patch:
diff --git a/test/pipelines/test_pipeline.py b/test/pipelines/test_pipeline.py
--- a/test/pipelines/test_pipeline.py
+++ b/test/pipelines/test_pipeline.py
@@ -813,8 +813,8 @@ def test_pipeline_classify_type():
     )
     pipe.get_type().startswith("TranslationWrapperPipeline")
 
-    # pipe = MostSimilarDocumentsPipeline(document_store=MockDocumentStore())
-    # assert pipe.get_type().startswith("MostSimilarDocumentsPipeline")
+    pipe = MostSimilarDocumentsPipeline(document_store=MockDocumentStore())
+    assert pipe.get_type().startswith("MostSimilarDocumentsPipeline")
 
 
 @pytest.mark.usefixtures(deepset_cloud_fixture.__name__)
diff --git a/test/pipelines/test_standard_pipelines.py b/test/pipelines/test_standard_pipelines.py
--- a/test/pipelines/test_standard_pipelines.py
+++ b/test/pipelines/test_standard_pipelines.py
@@ -229,6 +229,15 @@ def test_most_similar_documents_pipeline_batch(retriever, document_store):
             assert isinstance(document.content, str)
 
 
+@pytest.mark.integration
+@pytest.mark.parametrize("document_store_with_docs", ["memory"], indirect=True)
+def test_most_similar_documents_pipeline_save(tmpdir, document_store_with_docs):
+    pipeline = MostSimilarDocumentsPipeline(document_store=document_store_with_docs)
+    path = Path(tmpdir, "most_similar_document_pipeline.yml")
+    pipeline.save_to_yaml(path)
+    os.path.exists(path)
+
+
 @pytest.mark.elasticsearch
 @pytest.mark.parametrize("document_store_dot_product_with_docs", ["elasticsearch"], indirect=True)
 def test_join_merge_no_weights(document_store_dot_product_with_docs):