From 3fa58825ef4b8256046a948ebdd9caf6129bc3bf Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Fri, 8 Dec 2023 13:43:55 +0100 Subject: [PATCH] Add OpenSearchDocumentStore and Retrievers 2.0 to existing page (#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add OpenSearchDocumentStore and Retrievers 2.0 to existing page * Update opensearch-document-store.md --------- Co-authored-by: Tuana Çelik --- integrations/opensearch-document-store.md | 73 ++++++++++++++++++++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/integrations/opensearch-document-store.md b/integrations/opensearch-document-store.md index 7e6b9c9c..7feff378 100644 --- a/integrations/opensearch-document-store.md +++ b/integrations/opensearch-document-store.md @@ -1,31 +1,90 @@ --- layout: integration name: OpenSearch Document Store -description: Use an OpenSearch database with Haystack +description: A Document Store for storing and retrieval from OpenSearch authors: + - name: Thomas Stadelmann + socials: + github: tstadel + - name: Julian Risch + socials: + github: julian-risch - name: deepset socials: github: deepset-ai twitter: deepset_ai linkedin: deepset-ai -pypi: https://pypi.org/project/farm-haystack -repo: https://github.com/deepset-ai/haystack +pypi: https://pypi.org/project/opensearch-haystack +repo: https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/opensearch type: Document Store -report_issue: https://github.com/deepset-ai/haystack/issues +report_issue: https://github.com/deepset-ai/haystack-core-integrations/issues logo: /logos/opensearch.png +version: Haystack 2.0 +toc: true --- +### Table of Contents + +- [Haystack 2.0](#haystack-20) + - [Installation](#installation) + - [Usage](#usage) +- [Haystack 1.x](#haystack-1x) + - [Installation (1.x)](#installation-1x) + - [Usage (1.x)](#usage-1x) + +## Haystack 2.0 + +[![PyPI - Version](https://img.shields.io/pypi/v/opensearch-haystack.svg)](https://pypi.org/project/opensearch-haystack) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/opensearch-haystack.svg)](https://pypi.org/project/opensearch-haystack) +[![test](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/opensearch.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/opensearch.yml) + +----- + +## Installation +Use `pip` to install OpenSearch: + +```console +pip install opensearch-haystack +``` +## Usage +Once installed, initialize your OpenSearch database to use it with Haystack 2.0: + +```python +from opensearch_haystack import OpenSearchDocumentStore + +document_store = OpenSearchDocumentStore() +``` + +### Writing Documents to OpenSearchDocumentStore +To write documents to `OpenSearchDocumentStore`, create an indexing pipeline. + +```python +from haystack.components.file_converters import TextFileToDocument +from haystack.components.writers import DocumentWriter + +indexing = Pipeline() +indexing.add_component("converter", TextFileToDocument()) +indexing.add_component("writer", DocumentWriter(document_store)) +indexing.connect("converter", "writer") +indexing.run({"converter": {"paths": file_paths}}) +``` + +### License + +`opensearch-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license. + +## Haystack 1.x You can use [OpenSearch](https://opensearch.org/docs/latest/#docker-quickstart) in your Haystack pipelines with the [OpenSearchDocumentStore](https://docs.haystack.deepset.ai/docs/document_store#initialization) For a detailed overview of all the available methods and settings for the `OpenSearchDocumentStore`, visit the Haystack [API Reference](https://docs.haystack.deepset.ai/reference/document-store-api#opensearchdocumentstore) -## Installation +## Installation (1.x) ```bash pip install farm-haystack[opensearch] ``` -## Usage +## Usage (1.x) Once installed and running, you can start using OpenSearch with Haystack by initializing it: @@ -79,4 +138,4 @@ query_pipeline.add_node(component=retriever, name="Retriever", inputs=["Query"]) query_pipeline.add_node(component=prompt_node, name="PromptNode", inputs=["Retriever"]) query_pipeline.run(query = "Pizzas") -``` \ No newline at end of file +```