Package org.springframework.ai.document
Class Document.Builder
java.lang.Object
org.springframework.ai.document.Document.Builder
- Enclosing class:
- Document
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Deprecated, for removal: This API element is subject to removal in a future version.idGenerator
(IdGenerator idGenerator) Sets the media content of the document.Sets a score value for this document.Sets the text content of the document.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
idGenerator
-
id
-
text
Sets the text content of the document.Either text or media content must be set before building the document, but not both.
- Parameters:
text
- the text content- Returns:
- the builder instance
- See Also:
-
content
@Deprecated(since="1.0.0-M5", forRemoval=true) public Document.Builder content(@Nullable String text) Deprecated, for removal: This API element is subject to removal in a future version.since 1.0.0-M5, usetext(String)
instead as it more accurately reflects that this Document instance will contain text rather than generic content. This method will be removed in a future release.Sets the text content of the document.- Parameters:
text
- the text content to set- Returns:
- the builder instance
-
media
Sets the media content of the document.Either text or media content must be set before building the document, but not both.
- Parameters:
media
- the media content- Returns:
- the builder instance
- See Also:
-
metadata
-
metadata
-
score
Sets a score value for this document.Common uses include:
- Measure of similarity between the embedding value of the document's text/media and a query vector, where higher scores indicate greater similarity (opposite of distance measure)
- Text relevancy rankings from retrieval systems
- Custom relevancy metrics from RAG patterns
Higher values typically indicate greater relevance or similarity.
- Parameters:
score
- the document score, may be null- Returns:
- the builder instance
-
build
-
text(String)
instead as it more accurately reflects that this Document instance will contain text rather than generic content.