ElasticsearchReader#
- pydantic model llama_index.readers.ElasticsearchReader#
Read documents from an Elasticsearch/Opensearch index.
These documents can then be used in a downstream Llama Index data structure.
- Parameters
endpoint (str) – URL (http/https) of cluster
index (str) – Name of the index (required)
httpx_client_args (dict) – Optional additional args to pass to the httpx.Client
Show JSON schema
{ "title": "ElasticsearchReader", "description": "Read documents from an Elasticsearch/Opensearch index.\n\nThese documents can then be used in a downstream Llama Index data structure.\n\nArgs:\n endpoint (str): URL (http/https) of cluster\n index (str): Name of the index (required)\n httpx_client_args (dict): Optional additional args to pass to the `httpx.Client`", "type": "object", "properties": { "is_remote": { "title": "Is Remote", "default": true, "type": "boolean" }, "endpoint": { "title": "Endpoint", "type": "string" }, "index": { "title": "Index", "type": "string" }, "httpx_client_args": { "title": "Httpx Client Args", "type": "object" }, "class_name": { "title": "Class Name", "type": "string", "default": "ElasticsearchReader" } }, "required": [ "endpoint", "index" ] }
- Config
arbitrary_types_allowed: bool = True
- Fields
endpoint (str)
httpx_client_args (Optional[dict])
index (str)
is_remote (bool)
- field endpoint: str [Required]#
- field httpx_client_args: Optional[dict] = None#
- field index: str [Required]#
- field is_remote: bool = True#
- classmethod class_name() str #
Get the class name, used as a unique ID in serialization.
This provides a key that makes serialization robust against actual class name changes.
- load_data(field: str, query: Optional[dict] = None, embedding_field: Optional[str] = None) List[Document] #
Read data from the Elasticsearch index.
- Parameters
field (str) – Field in the document to retrieve text from
query (Optional[dict]) – Elasticsearch JSON query DSL object. For example: {“query”: {“match”: {“message”: {“query”: “this is a test”}}}}
embedding_field (Optional[str]) – If there are embeddings stored in this index, this field can be used to set the embedding field on the returned Document list.
- Returns
A list of documents.
- Return type
List[Document]