Skip to main content
SemQL is a query language for expressing subscriptions and searches over the Semantik broker. Queries describe geometric regions in embedding space rather than named topics — agents receive messages whose meaning falls within the declared region. SemQL has two equivalent, losslessly interconvertible representations:
  • Text syntax — SQL-like, human-readable
  • JSON wire format — canonical format used by the Noetive API
Either format can be submitted to the broker. The JSON serializer always emits ISO 8601 durations.

Query structure

A query has one required clause and three optional modifiers:

Clauses

DISTANCE

Nearest-neighbor sphere in embedding space. Matches messages whose embedding falls within a given cosine distance of the anchor.
Provide either within or top_k. If neither is set, the clause acts as a scoring signal without a hard threshold.

DIRECTION

Cone search in embedding space. Matches messages aligned with one or more concept directions, regardless of distance from the origin.
When toward is an array, the direction vector is the normalized mean of all embedded concepts.

CONTRAST

Attract/repel vector arithmetic. Matches messages semantically close to the attract concepts and far from the repel concepts.
The composite vector is normalize(mean(embed(attract)) − mean(embed(repel))).

Boolean composition

Combine clauses with AND, OR, and NOT. Use parentheses to control precedence.

Modifiers

PARTITION

Scopes the query to one or more namespaces. Without a PARTITION clause, the query searches the default namespace only.

WINDOW

Restricts results to messages published within a time window ending now.
JSON form uses ISO 8601 durations: "P7D", "PT48H", "PT30M".

LIMIT

Caps the number of results returned.

Anchors

An anchor is the reference point for a clause. Two forms are accepted: Natural language string — the broker embeds it automatically:
Raw float vector — skip embedding, use the vector directly:

Duration format

The text parser accepts both formats. The JSON serializer always emits ISO 8601.

Full examples


Reserved words

Reserved words are case-insensitive in text syntax. JSON uses lowercase keys exclusively.

Grammar reference