SSyncropel Docs

Semantic Search

Search records by meaning, not exact words. Describe what you are looking for and get the closest records, optionally narrowed by thread, actor or kind.

This page is for people running their own workspace or using the API. If you use a workspace created at syncropel.com, start with Your hosted workspace.

Overview

Semantic search answers the question "give me records that mean something like X", where X is free text. It sits alongside two other tools: use Find when you know words that actually appear in the record (names, phrases, identifiers; it needs no setup), and Query when you know the shape of what you want (body.kind, body.priority, an exact thread). Use semantic search when you only know the idea and want records about it, however they are worded.

Three entry points:

  • CLI: spl search "query"
  • HTTP: POST /v1/records/search with a JSON body
  • SDK: client.search({ query }) (TypeScript) or await client.search(query) (Python)

All three use the same embedding provider, which you configure once per workspace. The supported provider is Ollama, which runs locally at no cost. If you just need text search and don't want to configure a provider, use Find: it works everywhere with zero setup.

Prerequisites: configure an embedding provider

Semantic search is off by default. Before any search works, configure a provider:

# One-time setup: installs nothing; requires Ollama to already be running.
spl config embedding-provider set ollama \
  --endpoint http://localhost:11434 \
  --model nomic-embed-text

The workspace picks this up straight away; no restart is needed. To check:

spl config embedding-provider show

When no provider is configured, search requests return HTTP 503. Both SDKs report this separately (disabled: true on the result) so a UI can show a "set up Ollama" hint instead of an error.

To turn search off without changing other settings:

spl config embedding-provider clear

Quick Start

# Top 5 records semantically near "authentication failure logs".
spl search "authentication failure logs" -k 5
#1  0.847  r_3f4a...  KNOW   th_incident_42   ...
#2  0.812  r_8b21...  KNOW   th_incident_42   ...
#3  0.794  r_c0de...  DO     th_session_93    ...
...

From TypeScript:

import { Client, Identity } from "@syncropel/sdk";

const client = new Client({
  endpoint: "http://localhost:9100",
  identity: Identity.static("did:sync:user:alice"),
});

const result = await client.search({
  query: "authentication failure logs",
  k: 5,
});

if (result.disabled) {
  console.log("Semantic search not configured: run `spl config embedding-provider set ollama`");
} else {
  for (const hit of result.hits) {
    console.log(hit.score.toFixed(3), hit.record.id, hit.record.body);
  }
}

From Python:

from syncropel import Client, Identity

client = Client(
    endpoint="http://localhost:9100",
    identity=Identity.static("did:sync:user:alice"),
)

result = await client.search("authentication failure logs", k=5)

if result.get("disabled"):
    print("Semantic search not configured: run `spl config embedding-provider set ollama`")
else:
    for hit in result["hits"]:
        print(f"{hit['score']:.3f}  {hit['record']['id']}  {hit['record']['body']}")

Request Shape

{
  "query":        "free-text",
  "k":            10,
  "thread":       "th_optional",
  "actor":        "did:sync:agent:dev",
  "kind":         "core.task.record",
  "after_clock":  12345
}
  • query (required): the text to search for. Used exactly as written.
  • k: how many results to return. Clamped to [1, 100]. Default 10.
  • thread: restrict to one thread ID.
  • actor: restrict to records emitted by a specific actor DID.
  • kind: restrict to records whose body.kind matches.
  • after_clock: restrict to records with clock >= after_clock. Useful for time-windowed searches.

Filters are post-ranking

Filters narrow the best matches after ranking, not before. Syncropel finds the top K matches across all records, then applies your thread, actor, kind and after_clock filters to them.

This means a narrow filter can return fewer than K results, or none, when the closest matches sit just outside it. If you need strict filtering (for example, "only look inside this thread"), combine with Query: search broadly, then query each hit's thread. If you use filters, ask for a larger k.

Response Shape

{
  "embedder":  "ollama/nomic-embed-text",
  "k":         5,
  "hits": [
    {
      "score":  0.847,
      "record": { /* the full record */ }
    },
    ...
  ]
}
  • embedder: the provider and model used. null when search is disabled.
  • k: echoes the requested K (after clamp).
  • hits: ordered list, closest first.
    • score: similarity from -1 to 1, though in practice 0 to 1. Higher is closer.
    • record: the full record, with id, thread, actor, act, body, clock, and all the rest.

When search is not available (the workspace returns 503), the SDK returns:

{
  "embedder":  null,
  "k":         5,
  "hits":      [],
  "disabled":  true
}

Render this as a setup hint, not an error.

Patterns

"What have we said about X recently?"

spl search "migration concerns with the new auth layer" \
  --after-clock $(($(date +%s) - 7 * 86400)) \
  -k 20

Combines free-text relevance with a 7-day time window.

"Search this thread only"

spl search "race condition" --thread th_incident_42 -k 10

Useful for long-running threads where you want to find references to a concept inside the conversation.

"Search this actor's output"

spl search "feature flag rollout" --actor did:sync:agent:dev -k 10

Finds records written by a specific actor that match an idea. Handy for "what has the dev agent said about X?" or "what has this team member promised?"

"Search a specific kind"

spl search "login" --kind core.task.record -k 10

Narrows to task records whose body is semantically near "login."

Combining with query

Search is often the top of a funnel: find candidates by meaning, then use Query to drill into the structure. Example: find incident records semantically near "slow queries" and then query for their resolution status:

# 1. Find candidates
HIT_THREADS=$(spl search "slow query performance" --kind incident.report -k 5 --json \
  | jq -r '.hits[].record.thread')

# 2. For each thread, find its KNOW-with-resolved body
for thread in $HIT_THREADS; do
  curl -s -X POST http://localhost:9100/v1/records/query \
    -H 'content-type: application/json' \
    -d "{\"filter\":{\"thread\":\"$thread\",\"act\":\"KNOW\",\"body.resolved\":true}}"
done

When records become searchable

When you add a record, Syncropel takes the text from the top-level text fields of its body, asks your provider to describe its meaning, and stores that with the record. This happens before the add returns, so every new record is searchable immediately.

Records that existed before you set up a provider are not processed automatically. The easiest way to cover them is to re-load them from a backup (see Backup & recovery).

Providers

Supported provider:

ProviderDefault modelRuns whereCost
ollamanomic-embed-textLocal (your host)$0

nomic-embed-text is a small open model. Download it once:

ollama pull nomic-embed-text

Hosted providers are not supported.

Limits & Failure Modes

  • What guests write: Search doesn't find what guests write, even for you. You can still read it in its conversation.
  • Embedding provider reachability: if Ollama isn't running, the workspace logs an error when records are added (the record is still saved, but not searchable) and search returns 503. Restart the provider, and re-load any records you want searchable.
  • k clamp: k above 100 is quietly reduced to 100. For very large result sets, combine search (for relevance) with Query (for structural pagination).
  • Empty query: both SDKs raise an error on an empty query.
  • Filter + k interaction: if k=10 and your filters reject 9 of the top 10, you'll get a single hit. For dense filters where you need a guaranteed return size, request a larger k upfront.
  • SDKs on network errors: both SDKs return empty hits on network or server errors. Zero hits with disabled: false can mean "nothing similar" or "the request failed." The CLI reports the error.

Next Steps

  • Query: the structural complement. Use search to find candidates, query to drill into their structure.
  • TypeScript SDK, Python SDK: full client reference.
  • Body-Kind Manifests: for when you want rich-query filters on body fields to stay fast at scale.

On this page