Skip to content

Commit

Permalink
Add more docstrings for ElasticsearchDocumentStore
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Jan 9, 2024
1 parent 7be7e8f commit 352a22b
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@


class ElasticsearchDocumentStore:
"""
ElasticsearchDocumentStore is a Document Store for Elasticsearch.
It can be used with Elastic Cloud or your own Elasticsearch cluster.
Simple usage with Elastic Cloud:
```python
from haystack.document_store.elasticsearch import ElasticsearchDocumentStore
document_store = ElasticsearchDocumentStore(cloud_id="YOUR_CLOUD_ID", api_key="YOUR_API_KEY")
```
One can also connect to a self-hosted Elasticsearch instance:
```python
from haystack.document_store.elasticsearch import ElasticsearchDocumentStore
document_store = ElasticsearchDocumentStore(hosts="http://localhost:9200")
```
In the above example we connect with security disabled just to show the basic usage.
We strongly recommend to enable security so that only authorized users can access your data.
For more details on how to connect to Elasticsearch and configure security,
see the official Elasticsearch documentation:
https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/connecting.html
All extra keyword arguments will be passed to the Elasticsearch client.
"""

def __init__(
self,
*,
Expand All @@ -41,6 +66,11 @@ def __init__(
):
"""
Creates a new ElasticsearchDocumentStore instance.
When no index is explicitly specified, it will use the default index "default".
It will also try to create that index if it doesn't exist yet. Otherwise it will use the existing one.
One can also set the similarity function used to compare Documents embeddings. This is mostly useful
when using the `ElasticsearchDocumentStore` in a Pipeline with an `ElasticsearchEmbeddingRetriever`.
For more information on connection parameters, see the official Elasticsearch documentation:
https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/connecting.html
Expand Down

0 comments on commit 352a22b

Please sign in to comment.