elips/docs
Reference · Python

Python EQL Integration

EQL is a small, expression-oriented DSL — not SQL. It has a lexer, a recursive-descent parser, an AST, and an executor, and it produces the same Filter and QueryPlan objects the SDK builders produce. You run it from Python with client.query_eql() or directly on the native handle with client.native.query().

Overview

A statement starts with a verb — search, get, scan, add, or delete — all lowercase and case-sensitive. Query vectors are supplied as $name placeholders bound through the bindings argument. See the full grammar on the EQL reference.

query_eql() & native query()

python
# High-level client (Client / PersistentClient)
results = client.query_eql(
    'search in documents nearest $q k 10 where category = "tech" yield',
    {"q": query_vector},
)

# Or straight to the native Database handle
results = client.native.query(
    'search in articles nearest $vec k 5 where rating >= 4.5 yield',
    {"vec": [0.1] * 128},
)

Parameter bindings

Vector placeholders start with a dollar sign $name and are supplied through the bindings dictionary as float lists or NumPy 1-D vectors. (The old :name colon form never existed in the grammar.)

python
import numpy as np

vec_query = np.random.randn(128).astype(np.float32).tolist()

results = client.query_eql(
    """
    search in product_embeddings
        nearest $target_vec
        k 20
        where price <= 100.0 and in_stock = true
        yield
    """,
    {"target_vec": vec_query},
)

EQL statement syntax

  • search: search in <collection> nearest $vec [k <int>] [threshold <num>] [where <filter>] [rank_by <distance|field>] [project <*|field,...>] yield
  • get: get from <collection> id "<string-id>" yield
  • scan: scan in <collection> [where <filter>] [offset <int>] [limit <int>] yield
  • add: add in <collection> vector [0.1, 0.2, ...] [metadata { "key": value }]
  • delete: delete from <collection> id "<string-id>"

The pre-1.1 verbs seek/fetch/place/erase are still accepted as deprecated synonyms, and top still works as an alias for k. Text-first retrieval is not exposed through EQL — use collection.query(query_texts=...) for that.

Code examples

python
import elips

with elips.Client(dimension=4) as client:
    items = client.get_or_create_collection("items")
    items.add(embeddings=[[1.0, 0.0, 0.0, 0.0]], metadatas=[{"status": "active"}])
    items.add(embeddings=[[0.0, 1.0, 0.0, 0.0]], metadatas=[{"status": "archived"}])

    # Execute an EQL query
    hits = client.query_eql(
        'search in items nearest $q k 5 where status = "active" yield',
        {"q": [1.0, 0.0, 0.0, 0.0]},
    )
    print(f"Found active hits: {len(hits)}")