For AI agents: this page is also available as Markdown at /docs/ingesting-documents.md. Every docs page is: add .md to its URL. llms.txt lists them all.
Ingesting documents
Documents go into a collection as JSON posted to /v1/collections/{c}/documents. The collection must already exist (see Collections). The Ingest tab of a collection in the console and the MCP index_documents tool do the same thing, and Elasticsearch, OpenSearch and Solr clients can keep their own write APIs (see Other ways in).
#Document shape
A document is a JSON object with fields defined by its schema. Give every document an id so you can replace or delete it later.
{
"id": "b1",
"title": "The Way of Kings",
"genre": "fantasy",
"year": 2010,
"tags": ["epic", "fantasy"],
"location": [-74.006, 40.7128],
"embedding": [0.12, -0.08, 0.31]
}
- Field names must be defined in the collection's schema, match one of its templates, or end in a type suffix such as
_t,_sor_i. Anything else is rejected for that document. See Schemas and field types. - Arrays hold multiple values for one field. A multi-valued geo field is an array of
[lon, lat]pairs. A multi-valued field is returned as a list, even when a document sent a single value. - Geo points are
[longitude, latitude], in that order, or an object, GeoJSON, WKT, a"lat,lon"string or a geohash. See Geo points and queries. - Send vectors yourself, as arrays of numbers with the collection's
dims. WarpSearch does not create embeddings from text. See Vector search. - Nested documents preserve the relationship between fields in each child object. They are not currently accepted by these REST ingest routes; see Nested documents. Elasticsearch object mappings flatten properties and do not provide same-child matching.
- Names with
@or.(Elasticsearch style) work only for fields created through the Elasticsearch-compatible API; WarpSearch schema names use letters, digits and_. See Elasticsearch.
Not supported: automatic embedding on ingest. Compute embeddings in your pipeline and send them in the document.
#Send documents
POST /v1/collections/{c}/documents takes a JSON array, an object with a docs array, or NDJSON with one document per line.
curl -X POST "https://api.warpsearch.io/v1/collections/books/documents?commit=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{"id": "b1", "title": "Dune", "genre": "scifi", "year": 1965},
{"id": "b2", "title": "Dune Messiah", "genre": "scifi", "year": 1969}
]'
The _bulk API (the same at /compat/opensearch). refresh=true plays the part of commit=true:
curl -X POST "https://api.warpsearch.io/compat/es/books/_bulk?refresh=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/x-ndjson" \
--data-binary @- <<'DOCS'
{"index": {"_id": "b1"}}
{"title": "Dune", "genre": "scifi", "year": 1965}
{"index": {"_id": "b2"}}
{"title": "Dune Messiah", "genre": "scifi", "year": 1969}
DOCS
curl -X POST "https://api.warpsearch.io/compat/solr/books/update?commit=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{"id": "b1", "title": "Dune", "genre": "scifi", "year": 1965},
{"id": "b2", "title": "Dune Messiah", "genre": "scifi", "year": 1969}
]'
The options, responses and errors below are those of the WarpSearch endpoint; the compatible APIs answer in their own formats.
Options can also go inside an object body:
{"docs": [{"id": "b1", "title": "Dune"}], "commit": true, "all_or_none": false}
To send an existing NDJSON file, let curl pass the bytes through unchanged:
curl -X POST "https://api.warpsearch.io/v1/collections/books/documents" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/x-ndjson" \
--data-binary @books.ndjson
| Option | Meaning |
|---|---|
commit=true | Wait for the local commit that makes documents searchable. See Writes, visibility and durability. |
durability=true or durability=strong | Wait for local commit, or for commit plus object-store persistence on managed collections. Also accepted in a write envelope. |
all_or_none=true | Apply the whole request or nothing: one bad document rolls back the rest. The request must fit in a single backend update, so keep these batches small. |
The response reports the outcome:
{"status": "ok", "indexed": 2, "failed": 0, "took_ms": 14}
status is ok (everything written), partial (some failed) or error (nothing written).
#Replace a document
Posting a document with an existing id replaces the whole document, so fields you leave out are removed. The same call creates and replaces.
#Partial updates
Use PATCH /v1/collections/{c}/documents/{id} with operations such as:
{"set": {"genre": "classic"}, "upsert": false, "durability": "strong"}
Operations include set, remove, increment, decrement, add, add_unique and remove_value. upsert defaults to true; set it to false when a missing id should fail. For several documents, use POST /v1/collections/{c}/documents/_patch with a docs array, each entry carrying its id and operations. Elasticsearch _update and bulk update accept doc, doc_as_upsert and upsert.
Patches apply to the latest committed document and require retrievable fields. Partitioned collections do not support patches. Concurrent updates to the same id can overwrite each other; serialize those updates in your application. There is no compare-and-set guarantee. After an ambiguous failure, read the document before repeating an increment or append.
Delete by query is not supported. Delete by id instead.
#Get a document
curl https://api.warpsearch.io/v1/collections/books/documents/b1 \
-H "Authorization: Bearer $WARPSEARCH_API_KEY"
curl https://api.warpsearch.io/compat/es/books/_doc/b1 \
-H "Authorization: Bearer $WARPSEARCH_API_KEY"
curl "https://api.warpsearch.io/compat/solr/books/get?id=b1" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY"
This returns {"id": ..., "fields": {...}}. A document is readable once committed, not in real time, and it needs only the viewer role.
#Delete documents
# One document
curl -X DELETE "https://api.warpsearch.io/v1/collections/books/documents/b1?commit=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY"
# Many, by id
curl -X POST https://api.warpsearch.io/v1/collections/books/documents/_delete \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids": ["b1", "b2"], "commit": true}'
curl -X DELETE "https://api.warpsearch.io/compat/es/books/_doc/b1?refresh=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY"
_bulk takes delete actions for many ids.
curl -X POST "https://api.warpsearch.io/compat/solr/books/update?commit=true" \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"delete": ["b1", "b2"]}'
Deleting an id that does not exist succeeds. Deleting needs the writer role.
#Partial failures
A write can succeed for most documents and fail for a few and still return a normal HTTP response, so always read the body. It lists each failure with its position and id:
{
"status": "partial",
"indexed": 1,
"failed": 1,
"errors": [
{"index": 1, "id": "b2", "code": "unknown_field", "message": "Field not found: nosuffix"}
],
"took_ms": 9
}
A failed document leaves any older version with the same id untouched. Fix the documents named in errors and send just those again.
Values are checked against the field's type. A value that cannot be converted fails its document with invalid_value and a message naming the field; the other documents are indexed. Numeric strings such as "12" are accepted for numeric fields, and "abc" in an int field is rejected:
{"index": 1, "id": "b2", "code": "invalid_value", "message": "field 'year': cannot parse 'abc' as an integer"}
See Checks at ingest.
Large requests are split into several backend updates. If one fails after the first has been applied, the response is 207 and lists every remaining document as failed, with a warning that they were not written (and not committed, if you asked for a commit). Retry exactly those documents. Because writes replace by id, retrying is safe.
Other failures are not per document and are explained in Limits and errors:
| Status | Code | Meaning |
|---|---|---|
400 | invalid_request | Malformed body, or no documents. |
403 | forbidden | Your key has the viewer role, and writing needs writer. |
404 | not_found | The collection does not exist, or your key has no role on it. |
413 | request_too_large | Over your plan's documents or bytes per request. Send smaller batches. |
429 | rate_limited, resource_exhausted | Slow down and retry after Retry-After. |
503 | warming_up | The collection is loading from idle. Retry after Retry-After. |
#Batching and throughput
- Batch your writes. Every write request bills a minimum size, so thousands of one-document requests cost far more than a few large ones. See Pricing for the current guidance on batch size.
- Send batches from a few parallel workers, and honor
Retry-Afterwhen you are throttled. - Do not use
commit=trueon every batch of a bulk load. Commit on the last batch, or let WarpSearch commit on its own. - Large documents (several KB each) produce many small segments on a big load; a single
_forcemergethrough the Elasticsearch-compatible API after the load keeps refreshes fast. - Your plan sets the maximum documents and bytes per request. The limits are in the console and are described in Limits and errors.
#Other ways in
| Client | How it writes |
|---|---|
| Elasticsearch and OpenSearch | _bulk or the single-document _doc APIs at /compat/es or /compat/opensearch. Unknown indices are created on the fly when your key is allowed to create collections. update actions merge doc fields; scripts and conditional updates are refused. See Elasticsearch and OpenSearch. |
| Solr | /compat/solr/{collection}/update accepts JSON documents and add, delete by id and commit commands. Delete by query and atomic updates are not supported. See Solr. |
| turbopuffer | The turbopuffer SDKs write with upsert_rows or upsert_columns at /compat/turbopuffer, where a namespace is a collection. See turbopuffer compatibility. |
| AI agents | The MCP index_documents and delete_documents tools take the same shapes, with commit: true for immediate searchability. See Guide for AI agents. |
#Checklist
- Create the collection and its schema first.
- Use stable ids so loads can be repeated.
- Send batches, read every response body, retry only the failed documents.
- Commit on the last batch, then confirm with a count:
curl -X POST https://api.warpsearch.io/v1/count/books \
-H "Authorization: Bearer $WARPSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"language": "lucene", "query": "*:*"}'