Record Class EmbeddedDocument
java.lang.Object
java.lang.Record
org.springframework.ai.vectorstore.EmbeddedDocument
- Record Components:
document- the document to store; must not be nullembedding- the pre-computed embedding vector; must not be null, must be non-empty, and must contain only finite values (noNaNorInfinity). Caller-supplied vectors are validated here because, unlikeVectorStore.add(java.util.List<org.springframework.ai.document.Document>),upsertnever re-embeds through a trusted model.
A
Document paired with a pre-computed embedding vector, written to a
VectorStore via VectorStore.upsert(java.util.List) without invoking the
store's embedding model.
This is the "bring your own vector" entry point: the caller supplies the embedding — computed by a batch API, an external embedding pipeline, or exported from another system — and the store persists it as-is.
The embedding array is defensively copied on construction and on access, so the vector
held by an instance cannot be mutated after handoff. Equality compares the document and
the element-by-element contents of the embedding array; a record's generated
equals would compare the array by reference instead.
- Since:
- 2.1.0
- Author:
- Soby Chacko
-
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedDocument(Document document, float[] embedding) Creates an instance of aEmbeddedDocumentrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondocument()Returns the value of thedocumentrecord component.float[]Returns a copy of the embedding vector.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
embedding
public float[] embedding()Returns a copy of the embedding vector. Mutating the returned array does not affect this instance.- Returns:
- a defensive copy of the embedding vector
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
document
Returns the value of thedocumentrecord component.- Returns:
- the value of the
documentrecord component
-