elips/docs
Practice

Guides

Short, task-shaped walkthroughs. Each one starts from Getting started and ends with a runnable snippet.

A small RAG store

Persist chunked documents with lineage, query by text, and surface the original passage on every hit.

python
import elips

client = elips.PersistentClient("/var/lib/rag", dimension=384, metric="cosine")
docs = client.get_or_create_collection("docs")

for chunk in iter_chunks(corpus):
    docs.add(
        documents=[chunk.text],
        metadatas=[{"source": chunk.source_id, "page": chunk.page}],
    )

client.checkpoint()

for hit in docs.query(query_texts=["how do we rotate keys?"], n_results=5):
    print(hit.text, hit.meta, hit.distance)

Shared-reader fan-out

One writer process refreshes the database; many reader processes serve queries with read-only handles.

python
# writer.py — exclusive lock
writer = elips.PersistentClient("/srv/index", dimension=768)

# reader.py — shared lock, can run in N processes concurrently
reader = elips.PersistentClient("/srv/index", access_mode="read_only")
result = reader.get_collection("docs").query(
    query_texts=["status of incident 9412"], n_results=10
)

Reindex without downtime

Build a fresh index in a sibling directory, swap atomically, and let readers pick it up on their next open.

python
new = elips.PersistentClient("/srv/index.next", dimension=768)
hydrate(new)
new.compact()
new.close()

# atomic swap
os.rename("/srv/index", "/srv/index.prev")
os.rename("/srv/index.next", "/srv/index")

Bulk import

bash
elips import /srv/index --collection docs --input dump.jsonl --dimension 768
elips checkpoint /srv/index