Skip to content

REST API

Update fields of existing documents

POST/v1alpha1/indexes/{name}/documents/actions/updatedocuments.write

Changes named parts of documents already in the index, leaving the rest of each document unchanged. Each key in a change object is a path naming a location in the document: a path with a value replaces what the path names, a path set to null empties what it names, and an omitted path leaves the existing value unchanged.

The path replaces exactly what it names and leaves surrounding content unchanged. variants replaces every value of the field, variants[sku=V-2] replaces the object value whose sku field reads as V-2, and variants[sku=V-2].price replaces one field inside that value. Similarly, title replaces every variant and title[sv] replaces the Swedish variant. variants[] adds a value to the values the field holds.

Send application/json with a documents array containing change objects, or application/x-ndjson with one change object per line and no outer wrapper.

Unlike indexing, this endpoint describes modifications rather than desired state and requires existing documents. Multiple updates to the same document in a single batch apply in the order provided, and the updated document is validated as a whole.

Changes in a batch are applied in the order sent. The first refused change halts processing and fails the request; changes applied before the failure remain in the index. Every error names the change it is about: position counts the changes of the request from zero, processed says how many the index applied before the failure, and a newline-delimited body also carries line. Send ?onError=skip to apply the rest of the batch instead and read the refused changes from failed.

The index has to declare a primary key and retain document source copies.

Path parameters

namestringrequired
Name of the index to write to, optionally specifying a generation such as books@2.

Query parameters

missingstring
Behavior when a document key does not exist: fail (default) fails the request, while skip updates the remaining documents and returns the missing keys under missing.
Default
"fail"
Values
"fail", "skip"
onErrorstring
Behavior when the index refuses a change: fail (default) stops at the first one and fails the request, while skip applies the remaining changes and returns the refused ones under failed. A key nothing is indexed under is governed by missing instead when that says skip.
Default
"fail"
Values
"fail", "skip"

Body

UpdateRequestRequired

Field-level changes to documents already in an index. Every change to one document is applied and validated as a whole. If validation fails, the request is rejected and the document remains unchanged. For more information, see Update behavior.

documentsmap of any[]required
The changes, each carrying the primary key and the locations to change, applied in the order provided. Every other key is a path: a path with a value replaces what it names, a path set to null empties what it names, and an omitted path leaves the existing value unchanged. The path replaces exactly what it names: variants replaces every value of the field, while variants[sku=V-2].price replaces one field inside those values. For the whole syntax, see Change paths.
1 property
<key>any

Responses

200
The documents were updated.
UpdateResponse

The count of updated documents, and any keys or changes that were skipped.

updatedinteger
The number of documents updated.
Format
int32
Example
1998
missingstring[]
List of primary keys that were not found, in the order provided. Each key is text, whatever type the key field declares: a whole-number key 42 is returned as "42". Send a key back in the {key} path parameter or the after parameter as it came. For more information, see Primary keys on the wire. Holds keys only when the request is sent with ?missing=skip; a request sent without it fails on the first missing key. Always present, and empty when nothing was skipped.
The changes the index refused, in the order sent. Holds entries only when the request is sent with ?onError=skip; a request sent without it fails on the first refused change. A key nothing is indexed under is reported under missing instead when the request is sent with ?missing=skip. 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
positioninteger
Which entry of the batch this was, counted from zero. Matches the index in the path of each error.
Format
int32
Example
3
lineinteger
The line of the request body the entry starts on, counted from one. Present only for a newline-delimited body; a body that carries the entries in a documents array omits it.
Format
int32
Example
4
Everything wrong with the entry, in the shape the 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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
freshnessstring
A freshness token for the state the change lands in. Pass it as freshness.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.
Example
"AQoIcHJvZHVjdHMSATIYBw"
400
A change failed validation, or a path in it names something the index or the document does not hold. The arguments of each error carry where in the batch the change sat and how much of the batch had landed: position, processed, and line for 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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
document:not_found
A document the change names is not indexed and `missing` is `fail`.
index:no_primary_key
The index definition declares no primary key, so a document cannot be named.
document:source_not_kept
The index does not store document copies. Send the complete document instead.
document:patch:path_invalid
A path in the change could not be read.
document:patch:field_unknown
A path reaches into a field the index does not have.
document:patch:selector_unsupported
A path names one value of a field that holds neither locale variants nor objects.
document:locale_unknown
A path names a locale the field holds no variant for.
document:patch:add_unsupported
A change adds a value to a field that holds a single value.
document:patch:not_an_object
A path reaches inside a field whose values are not objects.
document:patch:selector_required
A path reaches into a list of objects without saying which value.
document:patch:no_match
A selector names no value the document holds. A selector never creates the value it names.
document:patch:key_unsupported
A path names one value of a list by a key that the field declares none of. Match on a field inside the value instead.
document:patch:match_not_an_object
A path matches on a field inside a list whose values are not objects.
document:patch:add_reaches_inside
A path reaches inside a value that the same change adds, which does not exist yet. Give the whole value instead.
document:patch:missing_invalid
`missing` is neither `fail` nor `skip`.
document:on_error_invalid
`onError` is neither `fail` nor `skip`.
request:body_required
The request carries no changes.
document:malformed
A line of the body could not be read as JSON.
document:not_an_object
A change is not an object keyed by path.
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_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.
document:primary_key_required
A change to some of a document carries no primary key, so it names no document.
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 changes read before that are applied; send the rest again.
401
The request carries no credential this node accepts. Absent, malformed, unknown and lapsed keys are all answered alike, so a refusal cannot be used to find out which keys exist. The response carries 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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
auth:unauthenticated
The request carries no credential this node accepts.
403
The API key does not have 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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
auth:forbidden
The key is accepted but does not hold the `documents.write` permission.
404
No index with the specified name exists on this node, or the API key lacks permissions on the index.
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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
index:not_found
The node holds no such index, or the key has no permission on it.
409
The index cannot be written to right now.
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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error 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.
413
The request body is larger than the node accepts. The node states one size for a body it holds in memory and another for a newline-delimited body it reads as it arrives; the 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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
request:body_too_large
The body passed the size the node accepts for a newline-delimited request. The changes read before that are applied; `processed` says how many, so the rest can be sent again.
502
The node holding the index did not answer.
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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error codes
indexer:unreachable
The request was forwarded to the index writer and the writer did not answer. Send it again.
503
The index is not open on the node right now.
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.

codestring
Identifies the failure type. For validation failures, this is validation and the individual problems are listed in errors. For all other failures, this matches the code of the single entry in errors.
Example
"validation"
messagestring
Human-readable message for log output. Match on code 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.
Example
"Request contains 2 errors"
All problems found in the request. A validation failure reports every field with a problem, so a caller can fix them in one pass rather than one request at a time.
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
The error code identifying this specific problem.
Example
"index:field:primary_key:multiple_unsupported"
messagestring
Human-readable description of this problem.
Example
"Field `id` is marked as a primary key and multiple, primary keys can not have multiple values"
pathstring
Location of the offending value in the request, such as fields.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.
Example
"id"
argumentsmap of string
The values the message was rendered with, so a client can render a message of its own from the code.
1 property
<key>string
Error 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.