POST /compose/search_slots/{db_name}/{namespace}¶
Searches across multiple slots simultaneously, with a different query and optional weight per slot. The final score is a weighted average of per-slot similarities.
Request¶
Content-Type: application/json
URL Parameters:
| Parameter | Description |
|---|---|
db_name |
Name of the database |
namespace |
Namespace within the database |
Body:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
slot_queries |
object | ✅ | — | Map of slot name → query config. See slot query format below |
top_k |
int | ❌ | 10 |
Number of results to return |
schema_json_data |
string | ❌ | null |
JSON string of the schema. Required if schema is not stored in metadata |
Slot query format — each entry in slot_queries can be a plain string or a full config object:
{
"subject": { "query": "Einstein", "mode": "filter", "threshold": 0.5 },
"predicate": { "query": "developed", "weight": 0.3, "encoding": "exact" },
"object": { "query": "physics", "weight": 0.7, "encoding": "semantic" }
}
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
query |
string | ✅ | — | Value to search for in this slot |
weight |
float | ❌ | 1.0 |
Relative weight for this slot's score contribution |
encoding |
string | ❌ | schema-inferred | Encoding override for this slot |
mode |
string | ❌ | schema or "rank" |
"filter" eliminates candidates below threshold; "rank" contributes to score |
threshold |
float | ❌ | schema or 0.0 |
Minimum similarity for filter mode (0.0 to 1.0) |
Behavior¶
Each slot query is encoded independently using its slot's encoding strategy (or the provided override). Slots with mode="filter" eliminate candidates whose similarity falls below threshold before ranking. Remaining candidates are scored by a weighted average of mode="rank" slots only. Semantic slot queries have their embeddings loaded into the cache before the Rust call.
A schema is required — either stored in metadata from ingest, or provided via schema_json_data.
Responses¶
200 OK¶
{
"status": "success",
"query_type": "multi_slot_search",
"slot_queries": {
"subject": "Einstein",
"predicate": { "query": "developed", "weight": 0.3 }
},
"count": 3,
"results": [
{
"_id": 14,
"_score": 0.874,
"data": {
"subject": "Einstein",
"predicate": "developed",
"object": "Relativity"
}
}
]
}
| Field | Description |
|---|---|
slot_queries |
The slot queries as provided |
count |
Number of results returned |
results |
Array of matches with _id, _score, and data |
Error Responses¶
| Status | Condition |
|---|---|
400 |
No schema found, none provided, or invalid slot query format |
404 |
Collection not found |
500 |
Unexpected internal error |
Notes¶
- Weights do not need to sum to 1.0 — they are used as relative importance signals.
- Filter-mode slots do not contribute to the ranking score. Multiple filter slots are conjunctive (AND).
- If
modeis not specified in the query, the schema-level default is used (defaults to"rank"). - For a single-slot query, prefer
/compose/search_slotfor simplicity. - Schema must be available — either stored from ingest or passed in
schema_json_data.
Example¶
import requests
SERVER_URL = "http://18.220.128.24:8000"
API_KEY = "yourapitoken"
def search_slots(db_name: str, namespace: str, slot_queries: dict, top_k: int = 10) -> dict:
response = requests.post(
f"{SERVER_URL}/compose/search_slots/{db_name}/{namespace}",
headers={"X-API-Key": API_KEY},
json={
"slot_queries": slot_queries,
"top_k": top_k,
},
)
response.raise_for_status()
return response.json()
result = search_slots(
db_name="my_db",
namespace="triples",
slot_queries={
"subject": "Einstein",
"predicate": {"query": "developed", "weight": 0.3, "encoding": "exact"},
"object": {"query": "physics", "weight": 0.7, "encoding": "semantic"},
},
top_k=5,
)
print(result)
Expected output:
{
"status": "success",
"query_type": "multi_slot_search",
"slot_queries": {
"subject": "Einstein",
"predicate": { "query": "developed", "weight": 0.3, "encoding": "exact" },
"object": { "query": "physics", "weight": 0.7, "encoding": "semantic" }
},
"count": 2,
"results": [
{ "_id": 14, "_score": 0.874, "data": { "subject": "Einstein", "predicate": "developed", "object": "Relativity" } },
{ "_id": 21, "_score": 0.741, "data": { "subject": "Einstein", "predicate": "wrote", "object": "physics paper" } }
]
}