elips/docs
Practice

Examples

Drawn directly from examples/python/ and examples/cpp/ in the repository.

Python — getting started

examples/python/01_getting_started.py
import elips

client = elips.Client(dimension=128)
docs = client.get_or_create_collection("documents")
docs.add(
    documents=["alpha design note", "beta incident runbook"],
    metadatas=[{"kind": "design"}, {"kind": "ops"}],
)

for hit in docs.query(query_texts=["alpha"], n_results=2):
    print(hit.key, hit.distance, hit.text, hit.meta)

C++ — getting started

examples/cpp/01_getting_started.cpp
#include "elips/elips.hpp"
#include <print>

int main() {
    auto db = elips::open(
        ":memory:",
        elips::Config{}.dimension(128).metric(elips::Metric::cosine));

    auto& docs = db->collection("documents");
    docs.add_document("alpha design note", {{"kind", std::string{"design"}}});
    docs.add_document("beta incident runbook", {{"kind", std::string{"ops"}}});

    for (auto const& hit : docs.search_text("alpha", 2)) {
        std::println("{} {} {}", hit.key.to_string(), hit.distance,
                     hit.document->text);
    }
}

EQL from the SDK

python
rows = client.query_eql(
    'search in documents nearest $q k 10 where kind = "design" project kind yield',
    {"q": query_vector},
)

Hybrid retrieval

python
hits = docs.query(
    query_embeddings=[query_vector],
    query_texts=["rotate KMS keys"],
    n_results=5,
    where={"kind": "runbook"},
)