Read a document by key
Reads the document indexed under the specified primary key, returning it as originally indexed. The document sits under document, so send that value back to POST /v1alpha1/indexes/{name}/documents to index it again.
The read is answered from a point-in-time snapshot of the index and sees committed data only, so a document indexed since the last commit is reported as missing and one removed since the last commit is still returned. To read a write back as soon as it lands, pass the freshness token the write returned in the X-Exofind-Freshness header.
The index has to declare a primary key and retain document source copies.
Read requests are served directly by whichever node receives them, using data that the node has pulled from storage, and are never forwarded to the writer.
Path parameters
keystringrequirednamestringrequiredbooks@2.Headers
X-Exofind-FreshnessanyResponses
DocumentResponse
One document read from an index by its primary key. The read is answered from a point-in-time snapshot and sees committed data only, so an uncommitted write is not visible. For more information, see Reading one document.
documentobjectPOST /v1alpha1/indexes/{name}/documents to index it again.freshnessstringX-Exofind-Freshness header of the next request, and that request is answered from this state or a later one whichever node it lands on. Opaque; pass it back unchanged. See Freshness."AQoIcHJvZHVjdHMSATIYBw"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
- search:value_invalid
- The key in the path cannot be read as the type of the primary key field.
- 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, so there is nothing to return.
- search:freshness:invalid
- The `X-Exofind-Freshness` header carries a token the engine did not issue. Pass a token back unchanged.
- search:freshness:version_unsupported
- The freshness token was issued in a format version this node does not read. The `version` argument carries it; send the request to a node of the release that issued the token.
- search:freshness:index_mismatch
- The freshness token is of another index than the one in the path. The `index` argument carries the index the token is of.
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.read 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.read` 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
- document:not_found
- Nothing is indexed under the key in the path, as of the last commit.
- 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
- index:closed
- The request raced the index being closed to free local resources. Sending it again reopens the index.
- search:freshness:unavailable
- The node did not reach the state the freshness token asks for within `EXOFIND_SEARCH_FRESHNESS_WAIT`. Send the request again after the `Retry-After` header.
Authorization
- Permission
- documents.read
- 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.