CouchbaseVectorGet

Retrieve a vector document by its ID.

Syntax

couchbaseVectorGet(cacheName, id)

Parameters

Parameter
Type
Required
Description

cacheName

String

Yes

Name of the cache configuration

id

String

Yes

Document ID to retrieve

Returns

Returns a struct containing the vector document:

  • id - Document ID

  • type - Document type ("vector_document")

  • text - Text content

  • embedding - Vector embedding array

  • metadata - Custom metadata struct

  • userId - User ID (if set)

  • conversationId - Conversation ID (if set)

  • createdAt - Creation timestamp

  • updatedAt - Last update timestamp

Returns an empty struct {} if document not found.

Examples

Basic Retrieval

Check if Exists

Get with Metadata

Get User Document

Verify Before Update

Get Conversation Context

Retrieve Multiple Documents

Validate Document Structure

Export Document

Notes

  • Empty struct returned - If document doesn't exist, returns {} instead of throwing error

  • Check existence - Use doc.isEmpty() or structKeyExists(doc, "id") to check

  • Java HashMap - Document is returned as HashMap (BoxLang is fully Java interop compatible)

  • No caching - Always fetches fresh data from Couchbase

  • Case sensitivity - Document IDs are case-sensitive

Error Handling

See Also

Last updated

Was this helpful?