elips/docs
Reference · Python

Python EQL Integration

ELIPS Query Language (EQL) brings a declarative, SQL-like query interface to vector search. You can execute EQL statements directly in Python via db.query() or engine.query().

Overview

EQL allows developers to combine vector similarity search, boolean metadata filtering, pagination, and projection into a single declarative query string with parameterized vector placeholders.

db.query() & engine.query()

python
# Execution via low-level Database handle
results = db.query(
    "SEARCH FROM documents SEEK :q TOP 10 WHERE category = 'tech'",
    bindings={":q": query_vector}
)

# Execution via modern Engine handle
hits = engine.query(
    "SEARCH FROM articles SEEK :vec TOP 5 WHERE rating >= 4.5",
    bindings={":vec": [0.1] * 1536}
)

Parameter Bindings

Vector parameter placeholders start with a colon :name and are supplied via the bindings parameter as a Python dictionary of float lists or NumPy 1D vectors.

python
import numpy as np

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

hits = engine.query(
    """
    SEARCH FROM product_embeddings
    SEEK :target_vec
    TOP 20
    WHERE price <= 100.0 AND in_stock = true
    """,
    bindings={":target_vec": vec_query}
)

EQL Statement Syntax

  • SEARCH: SEARCH FROM vault_name SEEK :vector TOP k [WHERE filter] [THRESHOLD score]
  • SCAN: SCAN FROM vault_name [WHERE filter] [OFFSET o] [LIMIT l]
  • FETCH: FETCH FROM vault_name WHERE id = 1042
  • DELETE: DELETE FROM vault_name WHERE id = 1042

Hybrid EQL Queries

python
hits = engine.query(
    """
    SEARCH FROM kb_articles
    SEEK :query_vec
    TEXT 'quantum computing algorithms'
    TOP 10
    WHERE section = 'research'
    HYBRID_WEIGHT 0.3
    """,
    bindings={":query_vec": text_embedding}
)

Code Examples

python
import elips

with elips.connect(":memory:", dimension=4) as engine:
    arena = engine.arena("items")
    arena.write(vector=[1.0, 0.0, 0.0, 0.0], meta={"status": "active"})
    arena.write(vector=[0.0, 1.0, 0.0, 0.0], meta={"status": "archived"})

    # Execute EQL query
    hits = engine.query(
        "SEARCH FROM items SEEK :q TOP 5 WHERE status = 'active'",
        bindings={":q": [1.0, 0.0, 0.0, 0.0]}
    )
    print(f"Found active hits: {len(hits)}")