Index documents
Indexes one or more documents into the specified index. Each document specifies its own primary key. Indexing a document with an existing key replaces the document under that key. Documents in a batch are processed in the order sent. The first refused document halts processing and fails the request; documents processed before the failure remain in the index. Every error names the document it is about: position counts the documents of the request from zero, processed says how many the index took before the failure, and a newline-delimited body also carries line. Send ?onError=skip to index the rest of the batch instead and read the refused documents from failed.
Format the request body as application/json with a documents array, or application/x-ndjson with one document object per line and no outer wrapper. Newline-delimited documents are indexed as they are read, so the node holds a buffer rather than the whole body and a single request can carry a whole dataset. A JSON body is held in memory and is bounded by a smaller size; both sizes are set by the deployment, and a body past either is refused with 413.
Changes become searchable and replicate to remote storage after the index commits. The writer commits automatically based on indexed document volume or elapsed time. To commit changes immediately, call POST /v1alpha1/admin/indexes/{name}/actions/commit.
The operation runs on the index writer node. A write request received by another node is forwarded automatically.
Path parameters
namestringrequired@ and the name of the generation, such as books@2.Query parameters
onErrorstringfail (default) stops at the first one and fails the request, while skip indexes the remaining documents and returns the refused ones under failed. A body that cannot be read as JSON fails the request either way.- Default
- "fail"
- Values
- "fail", "skip"
Body
Documents to index. A document specifies its own primary key. Indexing a document with an existing key replaces the document under that key; if an index definition does not declare a primary key, each request adds a new document. See How a document is shaped.
documentsmap of any[]requiredmultiple is an array, a locale-specific field an object keyed by locale tag, a geo point an object with lat and lon fields, a vector an array of numbers, an object field a nested JSON object, and a timestamp an ISO 8601 string. A field set to null is treated as omitted.1 property
<key>anyResponses
DocumentsResponse
The count of indexed documents, and any that were skipped.
indexedintegerfailed.- Format
- int32
2failedDocumentFailure[]?onError=skip; a request sent without it fails on the first refused document. Always present, and empty when nothing was skipped.Example
{ "position": 3, "line": 4, "errors": [ { "code": "document:field_unknown", "message": "Field `nonexistent` does not exist in index", "path": "documents[3].nonexistent", "arguments": { "position": "3", "processed": "3", "name": "nonexistent" } } ]}3 properties
positionintegerpath of each error.- Format
- int32
3lineintegerdocuments array omits it.- Format
- int32
4errorsErrorDetail[]errors of a failed request take.Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringfreshnessstringfreshness.atLeast on a search, or in the X-Exofind-Freshness header of a read, and that request is answered only once the node holds the change. Opaque; pass it back unchanged. See Freshness."AQoIcHJvZHVjdHMSATIYBw"path of each error identifies the document and field location as the body carries it, such as documents[1].nonexistent for a documents array and [1].nonexistent for a newline-delimited body. The arguments of each error carry the same place as numbers to resume from: position for the document, processed for how many documents the index took before it, and line for the line of a newline-delimited body.ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- document:malformed
- A line of the body could not be read as JSON.
- request:body_required
- The request carries no documents.
- document:not_an_object
- A document is not an object keyed by field name.
- document:on_error_invalid
- `onError` is neither `fail` nor `skip`.
- document:field_unknown
- A document gives a field the index does not have.
- document:field_inside_object
- A document gives a dotted path to a field inside an object instead of the object that holds it.
- document:field_required
- A document leaves out a field the definition marks as required.
- document:locale_unknown
- A value carries a locale the field does not hold values in.
- document:locale_unsupported
- A value carries a locale on a field that is not locale specific.
- document:object_required
- A field that holds objects is given a value that is not one.
- document:object_unsupported
- A field that does not hold objects is given one.
- document:multiple_unsupported
- A field that holds a single value is given several.
- document:multiple_per_locale_unsupported
- A field that holds a single value per locale is given several in one locale.
- document:object_key_duplicate
- Two values of an object field read the same under the key that tells them apart.
- document:number:value_invalid
- A number field is given a value that cannot be read as its type.
- document:number:value_out_of_range
- A number field is given a value outside the bounds its definition declares.
- document:geo_point:value_invalid
- A geo point field is given a value that is not a latitude and a longitude.
- document:geo_point:value_out_of_range
- A geo point field is given a point that is not on the earth.
- document:timestamp:value_invalid
- A timestamp field is given a value that is not an ISO 8601 date and time with an offset.
- document:vector:value_invalid
- A vector field is given a value that is not an array of floats.
- document:vector:value_not_finite
- A vector field is given a value that is not a finite number.
- document:vector:dimensions_mismatch
- A vector field is given a vector with other dimensions than the field declares.
- document:vector:value_zero
- A vector field compared by cosine is given a vector of only zeros.
- index:generation:unsettled
- The generation the index serves from kept changing while the write was made. Send the request again.
- request:body_unreadable
- The body stopped arriving part way through. The documents read before that are indexed; send the rest again.
WWW-Authenticate: Bearer.ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- auth:unauthenticated
- The request carries no credential this node accepts.
documents.write permission.ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- auth:forbidden
- The key is accepted but does not hold the `documents.write` permission.
ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- index:not_found
- The node holds no such index, or the key has no permission on it.
ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- indexer:unavailable
- No node is available to write the index. Send the request again once one is.
- index:out_of_date
- The index is synchronizing. Send the request again.
- index:readonly
- The node lost the writer role while the request ran. Send the request again to reach the new writer.
- reindex:target_busy
- An active reindex job holds the target generation. Wait for the job, or write to another generation.
limit argument carries the one this request passed, in bytes. A newline-delimited body also carries processed, how many documents the index took before the body was cut off, so the rest can be sent again.ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- request:body_too_large
- The body passed the size the node accepts for a newline-delimited request. The documents read before that are indexed; `processed` says how many, so the rest can be sent again.
ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- indexer:unreachable
- The request was forwarded to the index writer and the writer did not answer. Send it again.
ErrorResponse
The body of every failed request. Error codes use colon-separated namespaces such as index:field:name_invalid, are stable across API versions, and are never renamed or reused, so clients match on code rather than on message. See Errors.
codestringvalidation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors."validation"messagestringcode rather than on message. When a validation failure contains one problem, this is that problem's message. When it contains several, it reads Request contains N errors."Request contains 2 errors"errorsErrorDetail[]Example
{ "code": "index:field:primary_key:multiple_unsupported", "message": "Field `id` is marked as a primary key and multiple, primary keys can not have multiple values", "path": "id"}4 properties
codestring"index:field:primary_key:multiple_unsupported"messagestring"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"pathstringfields.title or documents[1].nonexistent. Names join with ., one element of a list reads [n] counted from zero, and a key of a free-form map such as metadata goes in brackets and double quotes when it holds a dot or a bracket, as metadata["build.sha"]. A field inside an object field carries its own dotted path, so a path here reaches a field the same way a query does. Omitted when the problem applies to the request as a whole. See API conventions."id"argumentsmap of string1 property
<key>stringError codes
- index:closed
- The request raced the index being closed to free local resources. Sending it again reopens the index.
Authorization
- Permission
- documents.write
- Checked on
- The index the path names
- Roles
writer,admin
An API key sent as a bearer token, such as Authorization: Bearer exok_4ff6b760264c1918_ePQcdT1O9HSATZoXfDbT8hhHGsP9VpZH. A key carries grants that pair permissions with index patterns; the permission each endpoint needs is named beside it. Nodes running with EXOFIND_AUTH_MODE=none accept requests without a credential, and a node with EXOFIND_AUTH_ANONYMOUS_KEY set serves requests that carry none with the permissions of that key.
Exofind is built by Level Four AB and is available under the Apache License 2.0.