POST /compose/search_slot/{db_name}/{namespace}¶
Searches within a single named slot rather than against full row vectors. For example, searching for "Einstein" only in the "subject" slot of Triple-encoded data, ignoring other slots entirely.
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 |
|---|---|---|---|---|
query |
string | ✅ | — | The value to search for within the slot |
slot |
string | ✅ | — | The slot to search within (e.g. "subject", "object") |
encoding |
string | ❌ | null |
Encoding type: "semantic", "exact", or "numeric". Auto-detected from schema if omitted |
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 |
Behavior¶
The query is encoded using the slot's encoding strategy, then compared only against the target slot's vector component in each row. This isolates the search to a specific structural position in the data.
If encoding is "semantic", the query embedding is loaded into the cache before the Rust search call.
A schema is required — either stored in metadata from ingest, or provided via schema_json_data.
Responses¶
200 OK¶
{
"status": "success",
"query_type": "slot_search",
"query": "Einstein",
"slot": "subject",
"count": 3,
"results": [
{
"_id": 14,
"_score": 0.961,
"data": {
"subject": "Einstein",
"predicate": "developed",
"object": "Relativity"
}
}
]
}
| Field | Description |
|---|---|
query |
The search query |
slot |
The slot that was searched |
count |
Number of results returned |
results |
Array of matches with _id, _score, and data |
Error Responses¶
| Status | Condition |
|---|---|
400 |
No schema found and none provided, or invalid query |
404 |
Collection not found |
500 |
Unexpected internal error |
Notes¶
- Slot search is more precise than full-row search when you know which structural position a value occupies.
- For searching across multiple slots simultaneously with different weights, use
/compose/search_slots. - 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_slot(db_name: str, namespace: str, query: str, slot: str, top_k: int = 10) -> dict:
response = requests.post(
f"{SERVER_URL}/compose/search_slot/{db_name}/{namespace}",
headers={"X-API-Key": API_KEY},
json={
"query": query,
"slot": slot,
"top_k": top_k,
},
)
response.raise_for_status()
return response.json()
result = search_slot(
db_name="my_db",
namespace="triples",
query="Einstein",
slot="subject",
top_k=5,
)
print(result)
Expected output:
{
"status": "success",
"query_type": "slot_search",
"query": "Einstein",
"slot": "subject",
"count": 2,
"results": [
{ "_id": 14, "_score": 0.961, "data": { "subject": "Einstein", "predicate": "developed", "object": "Relativity" } },
{ "_id": 17, "_score": 0.903, "data": { "subject": "Einstein", "predicate": "born_in", "object": "Ulm" } }
]
}