Skill

Query Couchbase Data for LlamaIndex

Loads documents from Couchbase clusters using SQL++ queries.

Works with couchbasellamaindex

57
Spark score
out of 100
Updated 4 days ago
Version 0.14.22
Models

Add to Favorites

Why it matters

Integrate your Couchbase data into LlamaIndex for advanced AI applications. This asset allows you to query your Couchbase cluster using SQL++ and load the results directly into LlamaIndex for further processing.

Outcomes

What it gets done

01

Connect to a Couchbase cluster using provided credentials or an existing client.

02

Execute custom SQL++ queries to retrieve specific data.

03

Load queried data into LlamaIndex documents, specifying text and metadata fields.

04

Prepare Couchbase data for use in LlamaIndex-powered AI workflows.

Install

Add it to your toolbox

Run in your project directory:

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

Capabilities

What this skill does

Query a database

Writes and executes SQL or NoSQL queries on databases.

Extract

Pulls structured data fields from unstructured text.

RAG index

Chunks, embeds, and indexes documents for semantic retrieval.

Overview

LlamaIndex Readers Integration: Couchbase

What it does

This integration loads documents from a Couchbase cluster. You can specify connection details or an initialized Couchbase client. It uses SQL++ queries to fetch data and allows you to define which fields become the document's text content and which become metadata.

How it connects

Use this integration when you need to load data from Couchbase into LlamaIndex.

Source README

LlamaIndex Readers Integration: Couchbase

pip install llama-index-readers-couchbase

This loader loads documents from Couchbase cluster.
The user specifies a Couchbase client or credentials to initialize the reader. They can specify the SQL++ query to
fetch the relevant docs.

Usage

Here's an example usage of the CouchbaseReader.

import os

from llama_index.readers.couchbase import CouchbaseReader

connection_string = (
    "couchbase://localhost"  # valid Couchbase connection string
)
db_username = "<valid_database_user_with_read_access_to_bucket_with_data>"
db_password = "<password_for_database_user>"

# query is a valid SQL++ query that is passed to client.query()
query = """
    SELECT h.* FROM `travel-sample`.inventory.hotel h
        WHERE h.country = 'United States'
        LIMIT 5
        """

reader = CouchbaseLoader(
    connection_string=connection_string,
    db_username=db_username,
    db_password=db_password,
)

# It is also possible to pass an initialized Couchbase client to the document loader
# from couchbase.auth import PasswordAuthenticator  # noqa: E402
# from couchbase.cluster import Cluster # noqa: E402
# from couchbase.options import ClusterOptions # noqa: E402

# auth = PasswordAuthenticator(
#    db_username,
#    db_password,
# )

# couchbase_client = Cluster(connection_string, ClusterOptions(auth))
# reader = CouchbaseLoader(client=couchbase_client)

# fields to be written to the document
text_fields = ["name", "title", "address", "reviews"]

# metadata fields to be written to the document's metadata
metadata_fields = (["country", "city"],)

documents = reader.load_data(
    query=query, text_fields=text_fields, metadata_fields=metadata_fields
)

This loader is designed to be used as a way to load data into LlamaIndex. See here for examples.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.