java.lang.Object
ai.docling.serve.api.chunk.response.Chunk

public class Chunk extends Object
Represents a chunk of a document after it has been processed by a Docling chunker.
  • Method Details

    • builder

      public static @NonNull Chunk.Builder builder()
    • toBuilder

      public @NonNull Chunk.Builder toBuilder()
    • getFilename

      public String getFilename()
      Filename of the source document.
      Returns:
      the filename of the source document
    • getChunkIndex

      public int getChunkIndex()
      Index of this chunk within the document.
      Returns:
      the zero-based chunk index
    • getText

      public String getText()
      The chunk text with structural context (headers, formatting).
      Returns:
      the formatted chunk text
    • getRawText

      public @Nullable String getRawText()
      Raw chunk text without additional formatting or context.
      Returns:
      the raw chunk text, or null if not included
    • getNumTokens

      public Integer getNumTokens()
      Number of tokens in the text, if the chunker is aware of tokens.
      Returns:
      the number of tokens, or null if not calculated
    • getHeadings

      public List<String> getHeadings()
      List of headings for this chunk.
      Returns:
      the list of headings
    • getCaptions

      public List<String> getCaptions()
      List of captions for this chunk (e.g. for pictures and tables).
      Returns:
      the list of captions
    • getDocItems

      public List<String> getDocItems()
      List of doc items references.
      Returns:
      the list of document item references
    • getPageNumbers

      public List<Integer> getPageNumbers()
      Page numbers where this chunk content appears.
      Returns:
      the list of page numbers
    • getMetadata

      public Map<String,Object> getMetadata()
      Additional metadata associated with this chunk.
      Returns:
      the metadata map
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object