elips/docs
Reference · Python

elips.connect()

elips.connect() is the primary, modern entry point for opening or initializing an ELIPS database in Python. It creates the underlying C++ database instance and wraps it in a high-level Engine handle.

Overview

The modern Python surface favors elips.connect() over raw database handle instantiation. It automatically configures vector dimensions, distance metrics, HNSW parameters, text embedder models, and durability guarantees.

elips.connect()

python
def connect(
    path: str = ":memory:",
    *,
    dimension: int = 128,
    metric: str = "cosine",             # "cosine", "euclidean", "dot_product"
    index_type: str = "hnsw",           # "hnsw", "exact", "ivf_flat", "ivf_pq"
    embedder: Embedder | None = None,   # Python callable or sentence-transformers model
    durability: str = "sync_on_commit", # "sync_on_commit", "wal_only", "in_memory"
    access_mode: str = "read_write",    # "read_write", "read_only"
    gpu: bool = False,
) -> Engine: ...

elips.connect_with_config()

python
def connect_with_config(
    path: str,
    config: Config,
    *,
    embedder: Embedder | None = None
) -> Engine: ...

Embedder Integration

You can pass any text-to-vector embedding function or object matching the Embedder protocol (e.g. SentenceTransformers, OpenAI, Ollama):

python
from sentence_transformers import SentenceTransformer
import elips

model = SentenceTransformer("all-MiniLM-L6-v2")

# Pass model directly to connect
with elips.connect("./my_db", dimension=384, embedder=model.encode) as engine:
    arena = engine.arena("docs")
    arena.write(text="ELIPS makes vector search embedded and fast.")
    
    hits = arena.probe_text("fast vector search", top=3)
    print(hits[0].text)

Context Manager Usage

Using connect() inside a Python with block guarantees that the database is flushed, checkpointed, and closed cleanly upon exiting the block:

python
with elips.connect("vectors.elips", dimension=1536) as engine:
    # Perform read/write operations
    pass
# Database handle is safely closed here

Code Examples

In-Memory Volatile DB

python
import elips

with elips.connect(":memory:", dimension=64, metric="euclidean") as engine:
    arena = engine.arena("quick_test")
    arena.write(vector=[0.1] * 64, meta={"tag": "test"})

Persistent Disk DB with GPU Acceleration

python
import elips

with elips.connect(
    "./gpu_db",
    dimension=1536,
    metric="cosine",
    durability="wal_only",
    gpu=True
) as engine:
    print(f"Connected to GPU: {engine.gpu_info()}")