Documents
Adds or updates a document in a collection so it can be searched.#
/lmkit/v1/search/documentsIndexes a document and makes its content searchable. Provide the document and the ids that identify it; how the collection is searched is decided by the collection's settings. Indexing an id that already exists replaces it in place; supplying the same content_hash that is already indexed is a no-op. The response 'outcome' field reports Created, Replaced, or Unchanged. Optionally set ttl_seconds to have the document expire automatically. If indexing takes longer than the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results. If the supplied input cannot be read as a supported file type, returns 415 Unsupported Media Type; other invalid or unreadable input returns 400 Bad Request.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection to index the document into. |
document_idrequired | string (uuid) | The id you assign to the document. Use it to delete the document later; it is also returned with search results. |
input | string | The document to index: plain text, a base64-encoded file, or an uploaded file id. Required, but validated inside the endpoint (not via model validation) so an empty input is logged and captured like any other indexing failure. |
input_format | How 'input' is provided. | |
name | string | Optional display name for the document. Returned with search hits. |
source_uri | string | Optional source location, for example a URL or file path. Returned with search hits. |
content_hash | string | Optional content hash for change detection and de-duplication. When a document with the same id and the same non-empty content hash is already indexed, the request is a no-op (it returns 'Unchanged' without re-processing). |
ttl_seconds | object (int32) | Optional time-to-live in seconds. When set, the document is automatically removed this many seconds after indexing. Omit for a document that never expires. |
custom_metadata | object | Optional free-form string key/value pairs stored with the document and returned with search hits. |
wait_for_embedding | boolean | Whether to compute the document's semantic embedding before the request returns. Defaults to false: the document is made full-text searchable immediately and its embedding is produced in the background, so ingestion does not block on inference and write throughput scales. Set to true only when the document must be semantically searchable the instant the call returns; this makes the call wait on the embedding model. Has no effect when the tenant has semantic search off. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 202 | Accepted | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 413 | Payload Too Large | |
| 415 | Unsupported Media Type | |
| 500 | application/json | Internal Server Error |
| 503 | application/json | Service Unavailable |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/search/documents" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string",
"document_id": "string",
"input": "",
"input_format": "PlainText",
"name": "string"
}'Removes a document from a collection.#
/lmkit/v1/search/documentsRemoves the document from the collection so it no longer appears in search results. Returns 404 Not Found if the document or its collection does not exist.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection the document belongs to. |
document_idrequired | string (uuid) | The document to delete. |
Responses
| Status | Type | Description |
|---|---|---|
| 204 | No Content | |
| 404 | Not Found | |
| 503 | Service Unavailable |
curl -X DELETE "$LMKIT_ONE_URL/lmkit/v1/search/documents" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string",
"document_id": "string"
}'Removes every document from a collection (asynchronous job).#
/lmkit/v1/search/documents/allDeletes all documents indexed in the collection (full-text, vector, and registry rows). A large collection holds hundreds of thousands of rows, so the delete ALWAYS runs as a background job that outlives the HTTP request: this returns 202 Accepted with a job_id immediately, the deletion runs in bounded committed batches that cannot be cancelled by a client disconnect or proxy timeout, and GET /lmkit/v1/jobs/ reports progress (progress_current = documents deleted so far, progress_total = the collection's document count) and finally result . Returns 404 Not Found when the collection does not exist.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection whose documents are all removed. |
Responses
| Status | Type | Description |
|---|---|---|
| 202 | Accepted | |
| 404 | Not Found | |
| 503 | application/json | Service Unavailable |
curl -X DELETE "$LMKIT_ONE_URL/lmkit/v1/search/documents/all" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string"
}'Lists the document ids a collection holds, for reconciliation.#
/lmkit/v1/search/documents/listReturns the public document ids currently indexed in the collection, ordered, one page at a time via 'offset' and 'limit' (a page shorter than 'limit' is the last). Lets a caller diff the server's contents against its own record of what it indexed, then delete documents the server still holds that the caller no longer tracks (orphans). Returns an empty list when the collection does not exist.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection to list documents from. |
offset | object (int32) | Number of leading documents to skip, for paging. Defaults to 0. |
limit | object (int32) | Maximum number of document ids to return in this page (clamped to 1..1000). A page shorter than the limit is the last page. Defaults to 200. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 503 | application/json | Service Unavailable |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/search/documents/list" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string",
"offset": 0,
"limit": 200
}'Fetches a single document by its id, with everything indexed for it.#
/lmkit/v1/search/documents/getReturns one document addressed by its id: its registry metadata (name, source, content hash, custom metadata, page count, and timestamps) and, by default, every page's Markdown and layout. Because a document can be large, the response can be trimmed: set 'include_pages' to false to get metadata only; set 'include_markdown' or 'include_page_layout' to false to drop those parts of each page (the omitted column is not even read from storage); and pass 'page_range' (a print-style string such as "1-3,7,10-12") to return only selected pages. 'page_count' is always the document's total page count, so a caller can page through a large document. Returns 404 Not Found when the document or its collection does not exist.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection the document belongs to. |
document_idrequired | string (uuid) | The id of the document to fetch, as supplied at index time. |
include_pages | boolean | Whether to include the document's per-page content at all. Defaults to true. Set to false to fetch only the document-level metadata (name, source, custom metadata, page count, timestamps) without any page bodies, the cheapest query. |
include_markdown | boolean | Whether each returned page includes its Markdown text. Defaults to true. Set to false to omit the page text (for example when only the layout is needed); the page Markdown is then not read from storage at all. Has no effect when include_pages is false. |
include_page_layout | boolean | Whether each returned page includes its layout (the text blocks and their positions captured at index time). Defaults to true. The layout is typically the largest part of the payload, so set this to false when only the Markdown is needed; the layout is then not read from storage at all. Has no effect when include_pages is false. |
page_range | string | Optional set of pages to return, as a 1-based page-range string in LM-Kit's standard syntax: a comma-separated list of single pages and ranges, for example "1-5", "3", or "1-5, 7, 9-12". An open bound is allowed ("5-" is page 5 through the end, "-3" is the first page through page 3), reversed ranges are normalized, and overlapping ranges never return a page twice. Omit, leave empty, or pass "*" to return every page; page numbers outside the document are ignored. Has no effect when include_pages is false. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 503 | application/json | Service Unavailable |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/search/documents/get" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string",
"document_id": "string",
"include_pages": true,
"include_markdown": true,
"include_page_layout": true
}'Lists the documents most similar to a given document.#
/lmkit/v1/search/documents/similarReturns the documents whose content most resembles the given document, most similar first - the document itself is never returned. The comparison uses the document vectors maintained for semantic search (no text and no inference is involved), so it requires semantic search enabled for the tenant, otherwise 400 Bad Request. Because embedding is deferred by default, a freshly indexed document may not be comparable yet: the response 'state' reports 'embedding_pending' (transient - poll again shortly) or 'no_content' (the document has nothing to compare - permanent), with empty results; results are meaningful only when it is 'ready'. Scores are cosine similarity in 0..1: near-duplicates (the same document re-scanned, re-exported, or lightly edited) typically score above 0.9. Pass 'search_collection_ids' to look across several of the tenant's collections in one call (they always share one embedding model); by default only the document's own collection is searched. 'filters' / 'filter' narrow the candidates by custom metadata with the same algebra as the search endpoint. Returns 404 Not Found when the document or its collection does not exist.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
cluster_id | string | The search cluster that holds the tenant and collection. If not provided, the default cluster is used. |
tenant_idrequired | string (uuid) | The tenant that owns the collection. |
collection_idrequired | string (uuid) | The collection the query document belongs to. |
document_idrequired | string (uuid) | The id of the document to find similar documents for, as supplied at index time. |
search_collection_ids | string (uuid)[] | The collections to look for similar documents in. Omit to search the query document's own collection. Several collections can be searched in one call (a tenant's collections always share one embedding model); unknown ids are skipped. The query document itself is never returned. |
top_k | object (int32) | Maximum number of documents to return (1..200). |
min_score | object (double) | Optional similarity floor: drop results scoring below this value. The score is the cosine similarity between document vectors, 0..1 - near-duplicates typically score above 0.9, unrelated documents well below. Defaults to 0 (no floor). |
verify_text | boolean | When true, each hit also carries 'text_similarity': the literal-text overlap (token-shingle containment, 0..1) between the two documents' stored content. The vector score says the documents TALK about the same thing; this says they ARE the same text - the check that separates a re-scanned or re-exported copy from two different documents built on the same template. Costs one stored-text read per hit; off by default. Null on a hit when either side has no comparable text. |
filters | object | Optional metadata filter: only documents whose custom_metadata contains all of these key/value pairs are returned. Applied during ranking, so top_k still returns the best matches that pass the filter. For operators beyond exact equality, use 'filter' instead; the two are mutually exclusive. |
filter | one of object · |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 503 | application/json | Service Unavailable |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/search/documents/similar" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cluster_id": "string",
"tenant_id": "string",
"collection_id": "string",
"document_id": "string",
"search_collection_ids": [
"string"
],
"top_k": 20,
"min_score": 0
}'