POST /select/¶
Executes a SQL-style SELECT query against an ingested namespace. Supports column projection, WHERE filtering, ORDER BY, LIMIT, OFFSET, and DISTINCT.
Request¶
Query Parameters:
| Parameter | Description |
|---|---|
db_name |
Name of the database |
namespace |
Namespace to query |
Body:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
columns |
list of string | ❌ | all | Columns to return. If empty, all columns are returned |
where |
list of condition | ❌ | — | Filter conditions |
logical_op |
string | ❌ | "and" |
How to combine WHERE conditions: "and" or "or" |
order_by |
list of order | ❌ | — | Sort fields |
limit |
int | ❌ | — | Max rows to return |
offset |
int | ❌ | 0 |
Number of rows to skip |
distinct |
bool | ❌ | false |
Remove duplicate rows |
WHERE condition object:
| Field | Type | Description |
|---|---|---|
field |
string | Column name to filter on |
operator |
string | One of: eq, ne, gt, gte, lt, lte, like, in, notin, isnull, isnotnull |
value |
string or list | Value to compare against. Use a list for in / notin |
ORDER BY object:
| Field | Type | Description |
|---|---|---|
field |
string | Column to sort by |
descending |
bool | true for descending, false for ascending (default) |
Behavior¶
Filters are applied in order against RocksDB row metadata. Numeric comparisons (gt, gte, lt, lte) automatically cast values to float. String operations (like) support % wildcards. All conditions are combined using logical_op (and by default).
Responses¶
200 OK¶
{
"total_rows": 3,
"execution_time_ms": 12.4,
"rows": [
{ "id": "E001", "name": "Alice", "department": "Engineering", "salary": "120000" },
{ "id": "E004", "name": "Dave", "department": "Engineering", "salary": "95000" }
]
}
| Field | Description |
|---|---|
total_rows |
Number of rows returned |
execution_time_ms |
Query execution time |
rows |
Array of row objects |
Error Responses¶
| Status | Condition |
|---|---|
404 |
Namespace not found |
500 |
Unexpected internal error |
Notes¶
likeoperator supports%prefix (%value), suffix (value%), and both (%value%).- Numeric comparisons work on string-stored numbers — they are cast to float at query time.
- Column projection happens after filtering, so WHERE can reference columns not in
columns.
Example¶
import requests
SERVER_URL = "http://18.220.128.24:8000"
API_KEY = "yourapitoken"
def select(db_name: str, namespace: str, query: dict) -> dict:
response = requests.post(
f"{SERVER_URL}/select/",
headers={"X-API-Key": API_KEY},
params={"db_name": db_name, "namespace": namespace},
json=query,
)
response.raise_for_status()
return response.json()
result = select("my_db", "employees", {
"columns": ["name", "department", "salary"],
"where": [
{"field": "department", "operator": "eq", "value": "Engineering"},
{"field": "salary", "operator": "gte", "value": "100000"},
],
"logical_op": "and",
"order_by": [{"field": "salary", "descending": True}],
"limit": 5,
})
print(result)
Expected output: