Query API¶
Query endpoints perform similarity search and metadata filtering entirely in the compressed TT-core domain — no dense materialization required.
Pairwise similarity¶
Compare two stored keys using core-native inner products.
Request body¶
| Field | Type | Required | Description |
|---|---|---|---|
key_a |
string | Yes | First key |
key_b |
string | Yes | Second key |
namespace |
string | No | Namespace (default: default) |
metric |
string | No | cosine (default), euclidean, or dot |
Example¶
Response — 200 OK¶
CU cost: 1.0
Top-K by stored key¶
Find the K most similar entries to an existing stored key.
Request body¶
| Field | Type | Required | Description |
|---|---|---|---|
query_key |
string | Yes | Reference key to compare against |
namespace |
string | No | Namespace (default: default) |
k |
int | No | Number of results (default: 10) |
metric |
string | No | cosine (default), euclidean, or dot |
filters |
object | No | Metadata filters to narrow candidates |
Example¶
Response — 200 OK¶
{
"query_key": "field_t42",
"metric": "cosine",
"n_candidates": 1200,
"results": [
["field_t43", 0.9987],
["field_t41", 0.9954],
["field_t44", 0.9921],
["field_t40", 0.9888],
["field_t45", 0.9812]
]
}
CU cost: 1.0
Top-K by external vector¶
Search for the K most similar entries to a vector you provide. The engine decomposes the incoming vector via TT-SVD on arrival, then performs core-vs-core similarity — no dense comparison needed.
Request body¶
| Field | Type | Required | Description |
|---|---|---|---|
data_b64 |
string | Yes | Base64-encoded NumPy array |
namespace |
string | No | Namespace (default: default) |
k |
int | No | Number of results (default: 10) |
metric |
string | No | cosine (default), euclidean, or dot |
filters |
object | No | Metadata filters to narrow candidates |
Example¶
Response — 200 OK¶
Same schema as Top-K by stored key.
CU cost: 1.0
Metadata search¶
Search for keys matching metadata filters. This does not perform similarity — it returns all matching entries.
Request body¶
| Field | Type | Required | Description |
|---|---|---|---|
filters |
object | Yes | Metadata key-value filters (exact match) |
namespace |
string | No | Namespace (default: default) |
Example¶
Response — 200 OK¶
{
"namespace": "telemetry",
"count": 3,
"results": [
{"key": "sensor_001", "metadata": {"source": "turbine_7", "unit": "Pa"}, "version": 1},
{"key": "sensor_042", "metadata": {"source": "turbine_7", "unit": "K"}, "version": 2},
{"key": "sensor_099", "metadata": {"source": "turbine_7", "unit": "m/s"}, "version": 1}
]
}
CU cost: 0.5
Metrics reference¶
| Metric | Formula | Range | Best for |
|---|---|---|---|
cosine |
$\frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{a}||\mathbf{b}|}$ | [-1, 1] | Directional similarity (default) |
euclidean |
$|\mathbf{a} - \mathbf{b}|_2$ | [0, ∞) | Absolute distance |
dot |
$\mathbf{a} \cdot \mathbf{b}$ | (-∞, ∞) | Raw inner product |
All metrics are computed in the compressed TT-core domain using core-native contractions. The computation cost is $O(d \cdot r^2)$ where $d$ is the number of TT-cores and $r$ is the maximum bond dimension — independent of the original data size.