Tool

Load Elasticsearch Data into LlamaIndex

LlamaIndex reader that loads documents from Elasticsearch or Opensearch indexes via REST API for downstream data processing and retrieval workflows.

Works with elasticsearchopensearchllama indexlangchain

71
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate Elasticsearch or OpenSearch data into LlamaIndex for advanced data processing and retrieval. This asset enables seamless data loading from your search index into LlamaIndex structures.

Outcomes

What it gets done

01

Connect to Elasticsearch/OpenSearch via REST API.

02

Retrieve documents from specified indices.

03

Extract text from designated fields within documents.

04

Optionally load embedding fields for vector search.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-elasticsearch | bash

Overview

LlamaIndex Readers Integration: Elasticsearch

The Elasticsearch Reader integration retrieves documents from Elasticsearch or Opensearch indexes using the basic search API over REST. It loads data into LlamaIndex data structures and can be used as a Tool in a LangChain Agent. The reader supports Elasticsearch JSON query DSL for filtering and can extract both text content and optional embedding fields. Use this reader when you need to pull existing documents from an Elasticsearch or Opensearch index into a LlamaIndex workflow, especially when you want to leverage Elasticsearch's query capabilities to filter specific subsets of data.

What it does

The Elasticsearch Reader integration for LlamaIndex retrieves documents from Elasticsearch or Opensearch indexes using the basic search API over REST. It loads data into LlamaIndex data structures and can be used as a Tool in a LangChain Agent.

When to use - and when NOT to

Use this reader when you need to pull existing documents from an Elasticsearch or Opensearch index into a LlamaIndex workflow, especially when you want to leverage Elasticsearch's query DSL to filter and retrieve specific subsets of data.

Do NOT use this reader if your data source is not Elasticsearch or Opensearch.

Inputs and outputs

You provide an Elasticsearch or Opensearch endpoint URL, an index name, a field name to extract text from, and an Elasticsearch JSON query DSL object to filter documents. Optionally, you can specify an embedding field if your documents already contain vector embeddings, and pass additional httpx client arguments like timeout settings.

You receive documents that can be utilized in downstream LlamaIndex data structures.

Integrations

This reader is designed to load data into LlamaIndex and can subsequently be used as a Tool in a LangChain Agent.

Installation and usage

Install via pip:

pip install llama-index-readers-elasticsearch

Basic usage example:

from llama_index.core.schema import Document
from llama_index.readers.elasticsearch import ElasticsearchReader

# Initialize ElasticsearchReader
reader = ElasticsearchReader(
    endpoint="<Your Elasticsearch/Opensearch Endpoint>",
    index="<Index Name>",
    httpx_client_args={
        "timeout": 10
    },  # Optional additional arguments for the httpx.Client
)

# Load data from Elasticsearch
documents = reader.load_data(
    field="<Field Name>",  # Field in the document to retrieve text from
    query={"query": {"match_all": {}}},  # Elasticsearch JSON query DSL object
    embedding_field="<Embedding Field>",  # Field for embeddings (optional)
)

Who it's for

This reader is built for developers and data engineers who maintain document collections in Elasticsearch or Opensearch and want to incorporate that data into LlamaIndex-powered applications.

Source README

LlamaIndex Readers Integration: Elasticsearch

Overview

Elasticsearch (or Opensearch) Reader over REST API is a tool designed to read documents from an Elasticsearch or Opensearch index using the basic search API. These documents can then be utilized in downstream LlamaIndex data structures.

Installation

You can install Elasticsearch (or Opensearch) Reader via pip:

pip install llama-index-readers-elasticsearch

Usage

from llama_index.core.schema import Document
from llama_index.readers.elasticsearch import ElasticsearchReader

### Initialize ElasticsearchReader
reader = ElasticsearchReader(
    endpoint="<Your Elasticsearch/Opensearch Endpoint>",
    index="<Index Name>",
    httpx_client_args={
        "timeout": 10
    },  # Optional additional arguments for the httpx.Client
)

### Load data from Elasticsearch
documents = reader.load_data(
    field="<Field Name>",  # Field in the document to retrieve text from
    query={"query": {"match_all": {}}},  # Elasticsearch JSON query DSL object
    embedding_field="<Embedding Field>",  # Field for embeddings (optional)
)

This loader is designed to be used as a way to load data into
LlamaIndex and/or subsequently
used as a Tool in a LangChain Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.