HTTP Gateway
The HTTP Gateway provides a RESTful HTTP/JSON interface to the Laurus search engine. It runs alongside the gRPC server and proxies requests internally:
Client (HTTP/JSON) --> HTTP Gateway (axum) --> gRPC Server (tonic) --> Engine
Enabling the HTTP Gateway
The gateway starts when http_port is configured:
# Via CLI argument
laurus serve --http-port 8080
# Via environment variable
LAURUS_HTTP_PORT=8080 laurus serve
# Via config file
laurus serve --config config.toml
# (set http_port in [server] section)
If http_port is not set, only the gRPC server starts.
Endpoints
| Method | Path | gRPC Method | Description |
|---|---|---|---|
| GET | /v1/health | HealthService/Check | Health check |
| POST | /v1/index | IndexService/CreateIndex | Create a new index |
| GET | /v1/index | IndexService/GetIndex | Get index statistics |
| GET | /v1/schema | IndexService/GetSchema | Get the index schema |
| POST | /v1/schema/fields | IndexService/AddField | Dynamically add a field |
| DELETE | /v1/schema/fields/{name} | IndexService/DeleteField | Remove a field from the schema |
| PATCH | /v1/schema/fields/{name} | IndexService/UpdateField | Change a field’s type or options |
| PUT | /v1/documents/{id} | DocumentService/PutDocument | Upsert a document |
| POST | /v1/documents/{id} | DocumentService/AddDocument | Add a document (chunk) |
| GET | /v1/documents/{id} | DocumentService/GetDocuments | Get documents by ID |
| DELETE | /v1/documents/{id} | DocumentService/DeleteDocuments | Delete documents by ID |
| POST | /v1/documents:bulk | DocumentService/PutDocuments / AddDocuments | Bulk-ingest documents (?mode=put|add, default put) |
| POST | /v1/commit | DocumentService/Commit | Commit pending changes |
| POST | /v1/flush_wal | DocumentService/FlushWal | Force buffered WAL records durable without a full commit |
| POST | /v1/search | SearchService/Search | Search (unary) |
| POST | /v1/search/stream | SearchService/SearchStream | Search (Server-Sent Events) |
| POST | /v1/search/batch | SearchService/SearchBatch | Run several searches in one request |
API Examples
Health Check
curl http://localhost:8080/v1/health
Create an Index
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{
"schema": {
"dynamic_field_policy": "dynamic",
"fields": {
"title": {"text": {"indexed": true, "stored": true, "term_vectors": true}},
"body": {"text": {"indexed": true, "stored": true, "term_vectors": true}}
},
"default_fields": ["title", "body"]
}
}'
The dynamic_field_policy key is optional. It controls how fields absent
from the schema are handled at ingest time. Accepted values: "strict",
"dynamic" (default), "ignore". null is the same as omitting the key;
any other value, including one that is not a string, is rejected with 400
(Issue #1473). See
Schema & Fields for the
full semantics and the warning about silent truncation under "dynamic".
schema must be an object, default_fields an array of strings, and
analyzers and embedders objects; in an analyzer, char_filters and
token_filters must be arrays. null is the same as omitting one of these
keys. Anything else, such as "default_fields": "title" or
"default_fields": [1, "title"], is rejected with 400 and no index is
created (Issue #1524). A server older than this fix read such a value as
omitted, or dropped the item that was not a string.
An analyzer’s char filters, tokenizer and token filters take the shapes of
Schema Format → Analyzers, such
as {"type": "stop", "words": ["new,york", "the"]}, and the server reads
them by the rules schema.toml is read by (Issue #1478). Each must be an
object nested at most 8 levels deep. A missing required key, an unknown
type, a key the component does not take (also on one that takes no
parameters, such as "words" on a lowercase filter; Issue #1700) or a
value of the wrong type, such as "min_gram": "2" or "words": "a,b", is
rejected with 400 and no index is created; the message names the analyzer
and the component, as in
Analyzer 'a': token_filters[0]: invalid type: string "a,b", expected a sequence.
A whole number such as 2.0 also fills an integer parameter, and null is
the same as omitting a key, so a key the component does not take is not
reported when its value is null. GET /v1/schema returns each component in the
same shape, with the defaults filled in, so the response can be posted
back. A server older than this fix joined a list into one comma-separated
string and split it again, so a stop word with a comma became two words
and each word lost its surrounding spaces; it dropped an array item or a
mapping value that was not a string, took "2" for a number, read a
misspelled boolean such as "False" as its default, and returned every
parameter as a string, with a mapping’s entries at the top level of the
component.
An embedder in embedders takes the shape of
Schema Format → Embedders, such
as {"type": "candle_colbert", "model": "colbert-ir/colbertv2.0", "query_maxlen": 32},
and the server reads it by the rules schema.toml is read by (Issue #1702).
It must be an object nested at most 8 levels deep. A missing model, an
unknown type, a key the type does not take (such as a misspelled
"doc_max_len", or "model" on a precomputed embedder) or a value of the
wrong type (such as "query_maxlen": "32" or "model": true) is rejected
with 400 and no index is created; the message names the embedder. A whole
number such as 32.0 also fills query_maxlen or doc_maxlen, and null
is the same as omitting a key. GET /v1/schema returns each embedder in the
same shape, so the response can be posted back. A server older than this
fix stored "32" as the number 32 and 123 or true as a string, and
dropped a key the type does not take, with a 200. For example:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"body": {"text": {}}}, "embedders": {"colbert": {"type": "candle_colbert", "model": "colbert-ir/colbertv2.0", "doc_max_len": 300}}}}'
# => {"error":{"code":400,"message":"Embedder 'colbert': unknown field `doc_max_len`, expected one of `model`, `revision`, `query_maxlen`, `doc_maxlen`"}}
The rest of a schema in the body (an analyzer’s char_filters, tokenizer
and token_filters keys, the field options and the schema’s top level) is
read by the gateway itself, which rejects a key it does not take there too,
such as "indexd" in a text field option (see
Request/Response Format; Issue #1706).
A schema that is read but that the engine cannot use is rejected with 400
too, and no index is created (Issue #1730): a text field whose analyzer is
not defined, an analyzer with a wrong setting (a malformed regular
expression, ngram sizes out of order, or an unknown mode, form or
stem_type), or a vector field whose embedder is not declared or does not
fit it. The message names the field, and POST /v1/schema/fields answers the
same. A Lindera dictionary that cannot be loaded is a 500. A server older
than this fix answered 500 to all of these on POST /v1/index. For example:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"body": {"text": {"analyzer": "trigram"}}}, "analyzers": {"trigram": {"tokenizer": {"type": "ngram", "min_gram": 3, "max_gram": 2}}}}}'
# => {"error":{"code":400,"message":"Invalid argument: Failed to resolve analyzer for field 'body': max_gram (2) must be >= min_gram (3)"}}
If the data directory has a store/ but no schema.toml, the request is
rejected with 412 and nothing is written or removed, since the store/ may
hold the documents of an earlier index (Issue #1560). Restore schema.toml
and restart the server to open that index, or remove store/ to create a
new one. A server older than this check opened such a store/ as the new
index’s storage and served its documents.
Get Index Statistics
curl http://localhost:8080/v1/index
Get Schema
curl http://localhost:8080/v1/schema
With no index, it answers 412 with {"error":{"code":412,"message":"No index is open"}}, as the other routes that need an index do (Issue #1724). A server older than this fix answered 500, naming the OS error of the missing schema.toml twice.
The response always includes multi_valued for text, integer, float, boolean, date_time, geo, geo3d, and bytes options (e.g. "location": {"geo": {"indexed": true, "stored": true, "multi_valued": true, "doc_values": true}}, "seen_at": {"date_time": {"indexed": true, "stored": true, "multi_valued": true, "doc_values": true}}, "flags": {"boolean": {"indexed": true, "stored": true, "multi_valued": true, "doc_values": true}}, "notes": {"text": {"indexed": true, "stored": true, "multi_valued": true, "position_increment_gap": 100}} or "thumbnail": {"bytes": {"stored": true, "multi_valued": true}}); the same keys are accepted on POST /v1/index and POST /v1/schema/fields. Their boolean keys (indexed, stored, multi_valued, doc_values and term_vectors) must be true or false, and null is the same as omitting the key, which means false for multi_valued and the engine default (true) for indexed, stored, doc_values and term_vectors, as in schema.toml. A server older than Issue #1709 read an omitted indexed or stored as false, so {"text": {}} created a field that was neither searchable nor returned. Anything else, such as "true" or 1, is rejected with 400 and nothing is written, instead of being read as omitted (Issue #1511). A text option’s position_increment_gap (Issue #1175) may be omitted on input — an omitted value means the engine default (100), not 0 — and is always present in the response. It must be an integer between 0 and 4294967295, and null is the same as omitting it; anything else, such as "0", -1 or 4294967296, is rejected with 400 instead of being read as omitted (Issue #1490). A bytes option has no indexed or doc_values key: a Bytes value is never indexed or written to DocValues regardless of multi_valued (Issue #1176).
A field option has exactly one type key, such as "text" or "hnsw", and its value is an object; a type key set to null next to another one is the same as omitting it. {"text": 1}, {"text": null} and {"text": {}, "integer": {}} are rejected with 400 on POST /v1/index, POST /v1/schema/fields and PATCH /v1/schema/fields/{name}, and nothing is written (Issue #1524). A server older than this fix read {"text": 1} as a text field that is neither indexed nor stored, and used the first of two type keys. A text option’s analyzer is a name or an object such as {"language": "japanese", "dict": "...", "mode": "normal"}, whose mode and user_dict must be strings; null is the same as omitting analyzer, mode or user_dict. A server older than this fix rejected "analyzer": null with 400.
A multi-vector field (Issue #1177) is declared as "body_colbert": {"multi_vector": {"dimension": 128, "distance": "cosine"}} (distance is "cosine" or "dot_product", defaulting to "cosine"). Its value in a document is an array of equal-length numeric arrays, one per token vector ("body_colbert": [[0.1, 0.2, ...], [0.3, 0.4, ...]]). The field holds token vectors for late-interaction rescoring: it is not a vector-search target and is not returned with documents.
A multi-vector field may also name a token-level embedder (Issue #1349), declared in the schema’s embedders with its numeric options as JSON numbers: "embedders": {"colbert": {"type": "candle_colbert", "model": "answerdotai/answerai-colbert-small-v1", "revision": "934fa8bb4ce2284f4c2baa232d81aca4d076fa5e", "doc_maxlen": 300}} and "body_colbert": {"multi_vector": {"dimension": 96, "embedder": "colbert"}}. A document can then give the field text ("body_colbert": "how lifetimes work in rust"), which is embedded into token vectors. The embedder is read by the rules schema.toml is read by (see Create an Index).
A multi-vector field may also set storage (Issue #1346) to pick the on-disk element kind of its token vectors: "f32" (default, exact), "f16" (2x smaller than "f32", ~2⁻¹¹ relative error per element), "int8" (~4x smaller than "f32" at typical dimensions, using a per-vector scale), or "binary" (32x smaller, 1 bit per element; requires "distance": "cosine"). It may also set pool_factor, an integer: each document keeps about 1 / pool_factor of its token vectors (1, the default, keeps them all; 0 is rejected by the engine, and a value that is not a non-negative integer is a 400). The key is omitted from the response when it is 1. The value is a lowercase string, accepted case-insensitively on input, e.g. "body_colbert": {"multi_vector": {"dimension": 128, "storage": "int8"}}; an unrecognized value, or one that is not a string, is rejected with 400 (Issue #1473), and null is the same as omitting the key. The key is omitted from the response when storage is "f32", the default.
An hnsw, flat or ivf field may set distance to "cosine", "euclidean", "manhattan", "dot_product" or "angular" (a multi-vector field takes the same strings), and rerank_storage to "F32" to keep a full-precision copy of the vectors that a query with rerank_factor rescores against (see Two-stage rerank). Both are accepted case-insensitively. Omitting distance or setting it to null means "cosine", and omitting rerank_storage or setting it to null keeps no copy; in the response, rerank_storage appears only when it is "F32". Any other value, including one that is not a string, is rejected with 400 (Issue #1473), and nothing is written:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"embedding": {"hnsw": {"dimension": 384, "distance": "euclidian"}}}}}'
# => {"error":{"code":400,"message":"field \"embedding\": unknown distance \"euclidian\" (expected \"cosine\", \"euclidean\", \"manhattan\", \"dot_product\", or \"angular\")"}}
An hnsw, flat or ivf field may set quantizer to pick how its vectors are stored, e.g. "embedding": {"hnsw": {"dimension": 384, "quantizer": {"method": "product_quantization", "subvector_count": 48}}}. method is the gRPC QuantizationMethod name without its QUANTIZATION_METHOD_ prefix, in lower case, and is accepted case-insensitively:
method | Index types | Notes |
|---|---|---|
"scalar_8bit" | HNSW, Flat, IVF | The default when quantizer is omitted or null |
"float16" | HNSW, Flat, IVF | IEEE 754 half precision (Issue #623) |
"product_quantization" | HNSW | subvector_count must be at least 1 and divide dimension |
"product_quantization_fastscan" | HNSW | Experimental; the server must be built with the pq-fastscan feature. subvector_count must be at least 1 and divide dimension |
Product Quantization and PQ FastScan support only the Euclidean and
Cosine distance metrics (Issue #1458); creating or updating a field with
another distance is rejected with 400. An existing index with such a field
still opens with a warning. To repair it without losing vectors, use a
non-PQ quantizer with the same distance; changing the distance discards the
field’s vectors.
subvector_count is used only by the two product quantization methods, but with any method it must be an integer between 0 and 4294967295, and null is the same as omitting it: a value such as "48", 48.0 or -1 is rejected with 400 instead of being read as 0, and one above 4294967295 instead of wrapping around (Issue #1490). Any other method, including "none" (unquantized storage was removed in Issue #481), a quantizer without a string method, and "product_quantization_fastscan" on a server built without pq-fastscan are rejected with 400 (Issue #1459), and nothing is written:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"embedding": {"hnsw": {"dimension": 384, "quantizer": {"method": "pq", "subvector_count": 48}}}}}}'
# => {"error":{"code":400,"message":"field \"embedding\": unknown quantizer method \"pq\" (expected \"scalar_8bit\", \"product_quantization\", \"product_quantization_fastscan\", or \"float16\")"}}
For both product quantization methods, POST /v1/index, POST /v1/schema/fields and PATCH /v1/schema/fields/{name} reject with 400 a subvector_count of 0 (what an omitted subvector_count becomes) or one that does not divide dimension (Issue #1491), and nothing is written:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"embedding": {"hnsw": {"dimension": 384, "quantizer": {"method": "product_quantization", "subvector_count": 5}}}}}}'
# => {"error":{"code":400,"message":"Invalid argument: field 'embedding': HNSW product quantization subvector_count 5 must divide dimension 384 (got 384 % 5 = 4)"}}
A server older than this check accepts such a field and fails a later commit with 500. An index it created still opens, with a warning in the server log; see gRPC API → Product quantization subvector_count for how to repair the field.
The response always includes quantizer, with subvector_count 0 for a method that does not use it (e.g. "quantizer": {"method": "scalar_8bit", "subvector_count": 0}).
An hnsw field may set m and ef_construction, and an ivf field n_clusters and n_probe, all integers (Issue #1479). Omitting one or setting it to null gets the engine’s default (m 16, ef_construction 200, n_clusters 100, n_probe 1), the same as a TOML schema, and the response shows the value used. dimension has no default and must be set on every vector field. A value that is not an integer between 0 and 4294967295 (such as 16.0 or "16") is rejected with 400, and so are an m below 2, an ef_construction, n_clusters or n_probe of 0, and a dimension of 0; nothing is written:
curl -X POST http://localhost:8080/v1/index \
-H 'Content-Type: application/json' \
-d '{"schema": {"fields": {"embedding": {"hnsw": {"dimension": 384, "m": 1}}}}}'
# => {"error":{"code":400,"message":"Invalid argument: field 'embedding': HNSW m must be at least 2, got 1"}}
PATCH /v1/schema/fields/{name} (UpdateField) replaces the whole option, so a key omitted there also gets the default, not the field’s current value: an hnsw field with "m": 32 patched with {"field_option": {"hnsw": {"dimension": 2}}, "reindex": true} is rebuilt with m 16. A server older than this change reads an omitted value as 0, with which every document write fails (m) or every search returns no hits (n_probe), so set these explicitly when talking to an older server. An index such a server created still opens, with a warning in the server log; see gRPC API → Graph and cluster parameters for how to repair the field.
An hnsw field may also set default_ef_search, the size of the candidate list a search of the field uses when the request does not set vector_params.ef_search (Issue #644; see Schema and Fields → default_ef_search). Like m, it must be an integer between 0 and 4294967295, and anything else, such as "64", 64.0 or -1, is rejected with 400 and nothing is written (Issue #1490). Omitting it or setting it to null leaves it unset, and the response shows it only when it is set. A server older than this fix read such a value as unset, wrapped one above 4294967295 (4294967360 became 64), and left default_ef_search out of the schema in its responses. Because PATCH /v1/schema/fields/{name} replaces the whole option, a field copied from such a response into a PATCH loses its default_ef_search unless the copy sets it again.
A vector field’s base_weight must be a number, and its embedder (and an hnsw field’s pq_codebook_path) a string. null is the same as omitting the key. Anything else, such as "base_weight": "2", is rejected with 400 and nothing is written (Issue #1524); a server older than this fix read it as omitted, so "base_weight": "2" gave the engine default 1.0.
Add a Field (Dynamic Schema)
Adds a new field to the running index. The request body uses the same FieldOption JSON shape as POST /v1/index:
curl -X POST http://localhost:8080/v1/schema/fields \
-H 'Content-Type: application/json' \
-d '{
"name": "category",
"field_option": {"text": {"indexed": true, "stored": true}}
}'
The response returns the updated schema.
Delete a Field
Removes a field from the schema. The field name is supplied in the path:
curl -X DELETE http://localhost:8080/v1/schema/fields/category
A lexical field’s data is discarded from every segment, which takes time in proportion to the index. A vector field’s files stay until a field with the same name is added again. Per-field analyzers and embedders are unregistered. A field added again with the same name starts empty (see Removing a Field).
Change a Field
Changes an existing field’s type or options. The field name is supplied in the path, and the body holds the new option and two flags:
| Key | Required | Description |
|---|---|---|
field_option | Yes | The field’s new configuration, in the same FieldOption JSON shape as POST /v1/schema/fields. It replaces the whole option: a key left out is not taken from the field’s current option but gets its default (see Get Schema), and dimension, which has no default, must be given again |
reindex | No | true to apply a reindex or destructive change (default false) |
dry_run | No | true to classify the change without applying anything (default false) |
reindex and dry_run must be true or false, and null is the same as omitting them. Anything else, such as the string "true", is rejected with 400, and nothing is classified or applied (Issue #1511). A server older than this fix read such a value as false, so "dry_run": "true" applied the change.
The response holds the classification (metadata_only, reindex or destructive; see Changing a Field) and the schema after the change, which a dry run leaves unchanged. A destructive change also adds the field to the schema’s pending_reindex. For an index whose only field is embedding, created as {"hnsw": {"dimension": 384}}:
# See how a larger m would be classified, without applying it
curl -X PATCH http://localhost:8080/v1/schema/fields/embedding \
-H 'Content-Type: application/json' \
-d '{"field_option": {"hnsw": {"dimension": 384, "m": 32}}, "dry_run": true}'
# => {"classification":"reindex","schema":{"default_fields":[],"dynamic_field_policy":"dynamic","fields":{"embedding":{"hnsw":{"base_weight":1.0,"dimension":384,"distance":"cosine","ef_construction":200,"m":16,"quantizer":{"method":"scalar_8bit","subvector_count":0}}}}}}
# A flag that is not a boolean is rejected, and nothing is applied
curl -X PATCH http://localhost:8080/v1/schema/fields/embedding \
-H 'Content-Type: application/json' \
-d '{"field_option": {"hnsw": {"dimension": 384, "m": 32}}, "reindex": true, "dry_run": "true"}'
# => {"error":{"code":400,"message":"dry_run must be true or false"}}
# A reindex change is rejected without "reindex": true
curl -X PATCH http://localhost:8080/v1/schema/fields/embedding \
-H 'Content-Type: application/json' \
-d '{"field_option": {"hnsw": {"dimension": 384, "m": 32}}}'
# => {"error":{"code":400,"message":"Invalid argument: updating field 'embedding' requires rebuilding or discarding existing data (classified as Reindex); enable `reindex` to proceed"}}
# Apply it
curl -X PATCH http://localhost:8080/v1/schema/fields/embedding \
-H 'Content-Type: application/json' \
-d '{"field_option": {"hnsw": {"dimension": 384, "m": 32}}, "reindex": true}'
# => {"classification":"reindex","schema":{"default_fields":[],"dynamic_field_policy":"dynamic","fields":{"embedding":{"hnsw":{"base_weight":1.0,"dimension":384,"distance":"cosine","ef_construction":200,"m":32,"quantizer":{"method":"scalar_8bit","subvector_count":0}}}}}}
Upsert a Document (PUT)
Replaces the document if it already exists:
curl -X PUT http://localhost:8080/v1/documents/doc1 \
-H 'Content-Type: application/json' \
-d '{
"fields": {
"title": "Hello World",
"body": "This is a test document."
}
}'
Add a Document (POST)
Adds a new chunk without replacing existing documents with the same ID:
curl -X POST http://localhost:8080/v1/documents/doc1 \
-H 'Content-Type: application/json' \
-d '{
"fields": {
"title": "Hello World",
"body": "This is a test document."
}
}'
Bulk-Ingest Documents (POST)
Applies many documents in one call — entries are processed sequentially, in
input order, with one WAL fsync for the whole batch. ?mode=put (the
default) upserts (duplicate ids dedup, last wins); ?mode=add appends
chunks, so repeated ids accumulate:
curl -X POST 'http://localhost:8080/v1/documents:bulk?mode=put' \
-H 'Content-Type: application/json' \
-d '{
"documents": [
{"id": "doc1", "fields": {"title": "Hello"}},
{"id": "doc2", "fields": {"title": "World"}}
]
}'
# => {"applied": 2}
The call fails fast at the first entry that cannot be applied; already-applied entries are not rolled back (they become durable at the next commit), and the error names the failing position, so retrying the batch or its suffix is idempotent.
A write that fails at or after its write-ahead-log append (an I/O error, a
full disk) stops writes instead: every later write, commit and field change
returns 412 Precondition Failed until the server is restarted, which
replays the log and applies that write whole if its record reached the log in
full, or leaves it unapplied, never half applied (see
Failed Writes). A request that is
cancelled, or whose client disconnects, does not stop writes: each of its
documents is either applied in full or not written at all, and the ones
applied before the cancellation stay applied.
Get Documents
curl http://localhost:8080/v1/documents/doc1
Delete Documents
curl -X DELETE http://localhost:8080/v1/documents/doc1
Commit
curl -X POST http://localhost:8080/v1/commit
Flush WAL
Forces buffered WAL records durable without a full commit. Returns {} on success. This is a near no-op under the default per-record sync policy; under the group-commit policy it flushes the current partial batch on demand. Buffered changes stay invisible to search until a subsequent POST /v1/commit.
curl -X POST http://localhost:8080/v1/flush_wal
Search
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{"query": "body:test", "limit": 10}'
limit defaults to 10 and offset to 0 when absent or null. Since
Issue #1367 a value that is not a non-negative integer, or that does not fit a
32-bit unsigned integer, is rejected with 400 Bad Request; it used to fall
back to the default or wrap around. A search whose offset + limit exceeds
the server’s max_result_window (default 10,000) is
rejected with 400 Bad Request as well.
lexical_params takes the keys of the gRPC
LexicalParams message in snake_case. Its
timeout_ms must be an integer between 0 and 18446744073709551615;
omitting it, null and 0 mean no timeout. Anything else, such as "500",
500.0 or -1, is rejected with 400 Bad Request instead of searching
without a timeout (Issue #1490). Its parallel must be true or false;
omitting it and null mean false. Anything else, such as "true" or 1,
is rejected with 400 Bad Request instead of being read as false
(Issue #1511). Its min_score must be a number; omitting it and null
mean 0.0, no threshold. Lexical scores are never negative, so a negative
min_score is the same as 0.0. The gateway converts it to a 32-bit float,
so a number beyond about 3.4e38, such as 1e39, becomes infinite and is
rejected with 400 Bad Request, also in a request without a query
(Issue #1540); a server older than this fix returned no hits.
The body must be a JSON object and query a string; omitting query or
setting it to null means no query. Anything else is rejected with
400 Bad Request (Issue #1524). A server older than this fix read a query
that is not a string as no query, so "query": 5 with query_vectors ran a
vector-only search.
Search Sorted by a Field
lexical_params.sort_by sorts the hits by a field’s value instead of by
score:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "body:rust",
"limit": 10,
"lexical_params": {"sort_by": {"field": "year", "order": "desc"}}
}'
field must be a string; an empty string sorts by score. order is
"asc" or "desc", matched case-insensitively, and omitting it or setting
it to null means "asc". These are not the gRPC names such as
"SORT_ORDER_DESC". A sort_by that is not an object or has no string
field, and any other order, are rejected with 400 Bad Request
(Issues #1476, #1524). A server older than this fix sorted ascending for any
other order, such as "DESC", and sorted by score when sort_by had no
string field. sort_by applies only to a request with a query.
Search with Field Boosts
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "rust programming",
"limit": 10,
"field_boosts": {"title": 2.0}
}'
Each key must name a lexical field of the schema (or _id). An unknown
field, such as a typo, or a vector field is rejected with 400 Bad Request
instead of being silently ignored (Issue #1374). field_boosts must be an
object and each boost a number; a null boost is the same as leaving the
field out. Anything else, such as {"title": "2"}, is rejected with
400 Bad Request instead of being dropped (Issue #1524).
A boost multiplies the field’s scores, so it must be at least 0; 0 keeps
a match with a lexical score of 0. The gateway converts each boost to a
32-bit float, so a number beyond about 3.4e38 becomes infinite. A negative
boost (-0 included) or an infinite one is rejected with 400 Bad Request
(Issue #1540). Both the field and the boost are checked in a request without
a query too. A server older than this fix hid the hits of a negative boost,
returned a null score for a boost such as 1e39, and ignored field_boosts
in a request without a query.
Hybrid Search
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "body:rust",
"query_vectors": [{"vector": [0.1, 0.2, 0.3], "weight": 1.0}],
"limit": 10,
"fusion": {"rrf": {"k": 60}}
}'
query_vectors are added to the vector part of query, so a query with
only lexical clauses becomes a hybrid search, with or without
lexical_params / field_boosts (Issue #1366). Each entry needs a
non-empty numeric vector; weight (a number) and fields (an array of
strings) are optional, and null keeps their defaults. Any other shape is
rejected with 400 Bad Request instead of being dropped. A weight that
is negative, or too large for a 32-bit float, is rejected with 400
instead of inverting the ranking or giving null scores (Issue #1552).
0, and any weight that becomes zero as a 32-bit float (such as -0 or
-1e-50), means the default, 1.0, as over gRPC. A vector component too
large for a 32-bit float, which would become infinite, is rejected with
400, whatever the data, instead of returning no results, every document
at a score of 0, or inflated scores (Issue #1573). A vector whose length
differs from the dimension of a field in its fields, or of a field
vector_params.fields picks for it, is rejected with 400, whatever the
data, instead of failing with 500 or crashing the server (Issue #1575).
fusion takes exactly one of rrf ({"k": 60}) and weighted_sum
({"lexical_weight": 0.5, "vector_weight": 0.5}), each an object whose
numbers default to the values shown when omitted or null. Omitting
fusion uses RRF with k 60. A fusion with neither or both, or with a
value of the wrong type such as {"rrf": {"k": "1"}}, is rejected with
400 Bad Request (Issue #1524). A server older than this fix used the
default instead, and rrf when both were set.
k must be at least 0: each result list adds 1 / (k + rank), rank
starting at 1. Each weight must be between 0 and 1, with at least one
greater than 0; the gateway converts the weights to 32-bit floats, so a
positive weight too small for one, such as 1e-50, becomes 0. Any other
value is rejected with 400 Bad Request, even in a request with no hybrid
part (Issue #1540).
A server older than this fix clamped the weights into [0, 1] and returned
null scores for a k such as -1.
Search with Vector Parameters
vector_params takes the keys of the gRPC
VectorParams message in snake_case:
fields, score_mode ("weighted_sum", "max_sim" or
"late_interaction"), overfetch, min_score, rerank_factor and
ef_search. A key that is null or absent keeps its default. A key with the
wrong type, an unknown score_mode, or a rerank_factor / ef_search that
does not fit a 32-bit unsigned integer is rejected with 400 Bad Request, as
is any value the gRPC API rejects (Issue #1342).
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query_vectors": [{"vector": [0.1, 0.2, 0.3]}],
"vector_params": {"fields": ["title_vec"], "min_score": 0.5, "ef_search": 128},
"limit": 10
}'
Search with Highlighting
highlight requests highlighted fragments per field (Issue #1134). The
shorthand form is just a field list:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{"query": "body:rust", "limit": 10, "highlight": ["body"]}'
The full object form adds HighlightConfig knobs — max_fragments,
fragment_size, tag, css_class, require_field_match,
max_analyzed_chars, return_entire_field_if_no_highlight:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "body:rust",
"limit": 10,
"highlight": {"fields": ["body"], "max_fragments": 2, "tag": "em"}
}'
max_fragments and fragment_size must be integers between 0 and
4294967295, and max_analyzed_chars one between 0 and
18446744073709551615; null is the same as omitting the key, which keeps
the default. Anything else, such as "2", 2.0 or -1, is rejected with
400 Bad Request instead of falling back to the default or wrapping around,
even when fields is empty (Issue #1490). As over gRPC, a max_fragments
or fragment_size of 0 is rejected too.
require_field_match and return_entire_field_if_no_highlight must be
true or false, and null is the same as omitting the key, which keeps
the default. Anything else, such as "true" or 1, is rejected with
400 Bad Request instead of falling back to the default, even when fields
is empty (Issue #1511).
The shorthand must hold only strings, and in the object form fields must
be an array of strings and tag and css_class strings; null is the same
as omitting the key. A highlight that is neither an array nor an object,
or one of these keys with the wrong type, is rejected with
400 Bad Request instead of being dropped (Issue #1524). An empty field
list ([], {} or {"fields": []}) requests no highlighting, while the
gRPC API rejects an empty HighlightParams.fields.
Each result gains a "highlights" object, present only when at least one
field actually highlighted:
{"id": "doc1", "score": 1.2, "fields": {...}, "highlights": {"body": ["<em>Rust</em> is a systems programming language"]}}
highlight only affects fields that are stored: true text fields in the
schema, and highlighting always follows the request’s lexical query — a
filter_query never contributes highlighted terms and a vector-only
request produces no highlights at all. See Highlighting
for the full semantics.
Search with Rescore
rescore reorders the top window_size results (default 100) with
late interaction over a MultiVector field (Issue #1351). The query is text,
embedded by the field’s token-level embedder (a candle_colbert one), or
the query’s token vectors as an array of equal-length numeric arrays:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "body:lifetimes",
"limit": 10,
"rescore": {
"window_size": 100,
"late_interaction": {"field": "body_colbert", "text": "how do lifetimes work"}
}
}'
"rescore": {"late_interaction": {"field": "body_colbert", "vectors": [[0.1, 0.2], [0.3, 0.4]]}}
A rescored result’s score is its late-interaction (MaxSim) score. A
malformed rescore (missing field, both or neither of vectors and
text, unequal vector lengths) is rejected with 400 instead of being
ignored; so are the values the engine rejects (see
gRPC RescoreParams and
Late-Interaction Rescore).
null for vectors or text is the same as omitting it (Issue #1524).
Search with Grouping
group_by groups the results by a field’s value (Issue #1297); limit and
offset then count groups. Chunks added with POST /v1/documents/:id
share their _id, so grouping by it returns each document once, by its best
chunk, with up to group_size - 1 more of its chunks (group_size defaults
to 1, at most 100):
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{"query": "body:rust", "limit": 10, "group_by": {"field": "_id", "group_size": 2}}'
With three chunks added as manual and one as faq, the response is:
{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"group_key":"manual","id":"manual","inner_hits":[{"fields":{"body":"Borrowing in Rust"},"group_key":"manual","id":"manual","score":0.012359549291431904}],"score":0.012571428902447224},{"fields":{"body":"Why Rust has no garbage collector"},"group_key":"faq","id":"faq","score":0.010891089215874672}]}
A result gains "group_key" when it has a value and "inner_hits" when its
group has more results, each in the same shape. Like rescore, a malformed
group_by is rejected with 400 instead of being ignored:
{"error":{"code":400,"message":"group_by.field must be a string"}}
So are the values the engine rejects (see
gRPC GroupByParams and
Result Grouping).
Search with a Total Hit Count
track_total_hits counts the matching documents beyond the page
(Issue #1472). As in Elasticsearch, it takes an integer n, which counts
exactly up to n matches, true, which counts every match, or false,
which counts nothing; omitting it and null mean false. The response then
gains "total_hits", whose "relation" is "eq" for an exact count and
"gte" for a lower bound. With the four chunks of the
grouping example, three of which contain “rust”:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{"query": "body:rust", "limit": 1, "track_total_hits": true}'
{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.012571428902447224}],"total_hits":{"relation":"eq","value":3}}
With "track_total_hits": 2, the count stops at the threshold, and the total
is a lower bound:
{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.012571428902447224}],"total_hits":{"relation":"gte","value":2}}
A search without track_total_hits, or with false, counts nothing and
returns the body without "total_hits". Counting has a cost, so ask for no
more than you need: until the count reaches the threshold, the search cannot
skip the documents that block-max pruning would skip. What the total counts
for a vector, hybrid or grouped search is described in
Total hits.
Any value other than an integer, true, false or null, such as
"1000", 1.5 or -1, is rejected with 400 Bad Request instead of
searching without a total:
{"error":{"code":400,"message":"track_total_hits must be true, false or an integer between 0 and 18446744073709551615"}}
0 is rejected by the engine:
{"error":{"code":400,"message":"Invalid argument: track_total_hits must count at least 1 match, got UpTo(0)"}}
Streaming Search (SSE)
The /v1/search/stream endpoint returns results as Server-Sent Events (SSE). Each result is sent as a separate event:
curl -N -X POST http://localhost:8080/v1/search/stream \
-H 'Content-Type: application/json' \
-d '{"query": "body:test", "limit": 10}'
The response is a stream of SSE events:
data: {"id":"doc1","score":0.8532,"fields":{...}}
data: {"id":"doc2","score":0.4210,"fields":{...}}
With group_by, each event is one group: its best result, with its
inner_hits when group_size is above 1. For
"group_by": {"field": "_id"}:
data: {"fields":{"body":"Rust ownership rules for Rust programs"},"group_key":"manual","id":"manual","score":0.012571428902447224}
data: {"fields":{"body":"Why Rust has no garbage collector"},"group_key":"faq","id":"faq","score":0.010891089215874672}
The stream has no event for a total, so a request whose track_total_hits
asks for one (an integer or true) is rejected with 400 Bad Request
before any event (Issue #1472); use POST /v1/search for a
total:
{"error":{"code":400,"message":"a streamed search returns no total hit count; send track_total_hits to a search that is not streamed"}}
Batch Search
POST /v1/search/batch runs several independent searches in one request
(Issue #714). queries is an array whose elements each take the body of
POST /v1/search; the server runs them in parallel, and the
response holds one {"results": [...]} per query, in the order of
queries:
curl -X POST http://localhost:8080/v1/search/batch \
-H 'Content-Type: application/json' \
-d '{"queries": [{"query": "body:ownership"}, {"query": "body:garbage", "limit": 1}]}'
With the four chunks of the grouping example, the response is:
{"results":[{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.7456220984458923}]},{"results":[{"fields":{"body":"Why Rust has no garbage collector"},"id":"faq","score":0.9227996468544006}]}]}
Each query takes its own track_total_hits,
and its entry gains "total_hits" only when it asked for one (Issue #1472).
For {"queries": [{"query": "body:rust", "limit": 1, "track_total_hits": true}, {"query": "body:garbage", "limit": 1}]}:
{"results":[{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.012571428902447224}],"total_hits":{"relation":"eq","value":3}},{"results":[{"fields":{"body":"Why Rust has no garbage collector"},"id":"faq","score":0.9227996468544006}]}]}
An empty queries returns {"results":[]}. A body without queries is
rejected with 400 Bad Request (missing `queries` field), and so is a
queries that is not an array ( `queries` must be an array). Every
query is read before any runs, and one that is malformed, or whose
offset + limit exceeds max_result_window, is rejected with
400 Bad Request whose message starts with its position:
{"error":{"code":400,"message":"queries[1]: query must be a string"}}
A value the engine rejects, such as a group_size above 100 or an unknown
field, fails the whole request the same way, with the engine’s message after
the position (Issue #1553). When several queries fail, the message names the
first to fail, which is not necessarily the lowest position:
{"error":{"code":400,"message":"queries[1]: Invalid argument: group_by: group_size must be between 1 and 100, got 1000"}}
JSON Field Value Inference
When the gateway accepts a document body (PUT /v1/documents/{id} or
POST /v1/documents/{id}), each value inside fields is converted to the
engine’s DataValue type using the same
canonical json_to_document converter laurus-cli and laurus-mcp use, so all
three JSON-accepting transports agree on one document shape and the same
inference rules as schema-less ingestion. This keeps the HTTP and gRPC
paths in sync.
| JSON value | Resulting field type | Notes |
|---|---|---|
null | (skipped) | The field is omitted entirely — it is not sent to the engine at all, not even as an explicit null. |
true / false | boolean | |
integer (fits in i64) | integer | |
| float / large integer | float | |
"text" | text | |
[1, 2, 3] (all integers) | integer with multi_valued: true | Multi-valued numeric field. |
[1.0, 2.5] (any non-integer number) | float with multi_valued: true | |
[] (empty array) | (skipped) | Element type cannot be determined, so the field is skipped. |
{"latitude": ..., "longitude": ...} | geo | |
{"lat": ..., "lon": ...} / {"lat": ..., "lng": ...} | geo | Short aliases for latitude / longitude are accepted. |
{"x": ..., "y": ..., "z": ...} | geo3d | All three keys required, finite numbers, ECEF meters. Mixing with lat/lon keys is rejected. |
[{"latitude": 35.6, "longitude": 139.7}, ...] (all geo objects) | geo with multi_valued: true | Multi-valued geo field; the lat / lon / lng aliases are accepted. Documents are returned with the field rendered as an array of {"latitude", "longitude"} objects. |
[{"x": ..., "y": ..., "z": ...}, ...] (all 3D objects) | geo3d with multi_valued: true | Multi-valued 3D geo field, returned as an array of {"x", "y", "z"} objects. Mixing 2D and 3D objects in one array is rejected. |
["2024-01-01T00:00:00Z", "2024-06-15T21:00:00+09:00"] (all RFC 3339 strings) | date_time with multi_valued: true | Multi-valued datetime field (Issue #1184). Only RFC 3339 strings are recognized as datetimes here. Documents are returned with the field rendered as an array of RFC 3339 strings normalized to UTC (e.g. "2024-06-15T12:00:00+00:00"). |
["a", "b"] (all strings, not all RFC 3339) | text with multi_valued: true | Multi-valued text field (Issue #1175). Each element is analyzed on its own; a term query matches if any element contains the term, and a phrase query does not span two elements unless its slop reaches the field’s position_increment_gap (default 100). Documents are returned with the field rendered as an array of strings. |
[true, false] (all booleans) | boolean with multi_valued: true | Multi-valued boolean field (Issue #1180). A term query such as flags:true matches if any element equals the value. Documents are returned with the field rendered as an array of booleans. |
{"data": "<base64>", "mime": "..."} | bytes | mime is optional. Disambiguates a bytes payload from a plain string on a multimodal vector field’s Text-or-Bytes embedder input — see Schema and Fields. |
The gateway returns an HTTP 400 (Bad Request) when:
- An array contains mixed types or non-numeric elements
(e.g.
[1, "x"]or[true, 1]), or mixes 2D and 3D geo objects (e.g.[{"lat": ...}, {"x": ...}]). - An object does not match any of the supported shapes above (e.g. missing
latitude / longitude keys for 2D geo, missing any of
x/y/zfor 3D geo, or a non-stringdatakey). - A geographic latitude is outside
[-90, 90]or a longitude is outside[-180, 180]. - An object mixes markers from more than one supported shape (e.g.
lattogether withx, ordatatogether withlat). - A 3D ECEF coordinate is non-finite (
NaN/Inf). - An object mixes 2D (
lat/lon) and 3D (x/y/z) keys.
Vector and bytes fields cannot be inferred from JSON alone and must be
declared in the schema. Numeric arrays sent against a declared vector
field are coerced to a vector of f32 values automatically, so REST
clients can post embeddings as plain JSON arrays.
3D Geographic Queries
3D ECEF queries reuse the lexical DSL string passed via query. The gateway forwards it unchanged to the engine, so the same forms work over HTTP as over gRPC:
curl -X POST http://localhost:8080/v1/search \
-H 'Content-Type: application/json' \
-d '{
"query": "position:geo3d_distance(-3955182, 3350553, 3700276, 5000)",
"limit": 10
}'
See Query DSL → 3D Geographic Queries for geo3d_bbox and geo3d_nearest syntax.
Request/Response Format
All request and response bodies use JSON. The JSON structure mirrors the gRPC protobuf messages. See gRPC API Reference for the full message definitions.
Each key takes the JSON types the sections above describe (most take one; highlight, for example, takes an array or an object), and for a key that may be omitted, null is the same as omitting it. A value of another type is rejected with 400 Bad Request whose message names the key, and nothing is written or searched: the string "true" or the number 1 for a boolean (Issue #1511), and the string "2" for a number, the number 1 for a string, or a string or an array for an object (Issue #1524). A server older than these fixes read such a value as omitted, or dropped it. The server checks the parameters of an analyzer’s char filters, tokenizer and token filters (Issue #1478) and of an embedder (Issue #1702) instead: its message names the analyzer and the component, or the embedder, and then gives serde’s description of the problem, which names a missing key but, for a value of the wrong type, only the type expected (see Create an Index). In POST /v1/search/batch, the message starts with the position of the query that failed, such as queries[1]: query must be a string, and none of the queries is run.
Each object of a body takes only the keys the sections above describe. Any other key, such as a misspelled "indexd" in a text option, "dry_rn" in a field change or "limt" in a search, is rejected with 400 Bad Request whose message names the key and the object, and nothing is written or searched (Issue #1706). As for every key, null is the same as omitting it, so an unknown key set to null is not reported. The keys of a schema’s fields, analyzers and embedders, of field_boosts and of a document’s fields are names you choose, and are not checked; the server checks the keys of an analyzer component and of an embedder (see above). A server older than this fix dropped such a key: "dry_rn": true applied the change instead of trying it, and "limt" searched with the default limit. For example:
curl -X PATCH http://localhost:8080/v1/schema/fields/body \
-H 'Content-Type: application/json' \
-d '{"field_option": {"text": {"stored": false}}, "dry_rn": true}'
# => {"error":{"code":400,"message":"unknown key \"dry_rn\" in the request body (expected \"field_option\", \"reindex\", or \"dry_run\")"}}