Update fields of existing documents
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
namestringrequiredbooks@2.Query parameters
missingstringfail (default) fails the request, while skip updates the remaining documents and returns the missing keys under missing.- Default
- "fail"
- Values
- "fail", "skip"
onErrorstringfail (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
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[]requirednull 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>anyResponses
UpdateResponse
The count of updated documents, and any keys or changes that were skipped.
updatedinteger- Format
- int32
1998missingstring[]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.failedDocumentFailure[]?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
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"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.
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: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.
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 changes read before that are applied; `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.