类 Document

java.lang.Object
io.agentscope.core.rag.model.Document

@Deprecated(forRemoval=true, since="2.0.0") public class Document extends Object
已过时, 待删除: 此 API 元素将从以后的版本中删除。
since 2.0.0. The rag package is removed; integrate retrieval at the application layer.
Document class representing a document chunk in the RAG system.

This is the core data structure for RAG operations. Each document contains metadata, an optional embedding vector, and an optional similarity score.

The document ID is automatically generated as a deterministic UUID based on the document metadata (doc_id, chunk_id, and content), ensuring consistent IDs for the same content across different runs.

  • 构造器概要

    构造器
    构造器
    说明
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Creates a new Document instance.
  • 方法概要

    修饰符和类型
    方法
    说明
    double[]
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the embedding vector.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the document ID.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the document metadata.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the custom payload from document metadata.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets a specific payload value by key.
    <T> T
    getPayloadValueAs(String key, Class<T> targetClass)
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets a specific payload value by key and converts it to the specified type.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the similarity score.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Gets the document vector name.
    boolean
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Checks if the document payload contains a specific key.
    void
    setEmbedding(double[] embedding)
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Sets the embedding vector.
    void
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Sets the similarity score.
    void
    setVectorName(String vectorName)
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
    Sets the document vector name.
    已过时, 待删除: 此 API 元素将从以后的版本中删除。
     

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 构造器详细资料

    • Document

      public Document(DocumentMetadata metadata)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Creates a new Document instance.

      The document ID is automatically generated as a deterministic UUID based on the metadata (doc_id, chunk_id, and content).

      参数:
      metadata - the document metadata
  • 方法详细资料

    • getId

      public String getId()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the document ID.
      返回:
      the document ID (UUID string)
    • getMetadata

      public DocumentMetadata getMetadata()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the document metadata.
      返回:
      the document metadata
    • getEmbedding

      public double[] getEmbedding()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the embedding vector.
      返回:
      the embedding vector, or null if not set
    • setEmbedding

      public void setEmbedding(double[] embedding)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Sets the embedding vector.
      参数:
      embedding - the embedding vector
    • getScore

      public Double getScore()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the similarity score.
      返回:
      the similarity score, or null if not set
    • setScore

      public void setScore(Double score)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Sets the similarity score.
      参数:
      score - the similarity score
    • getPayload

      public Map<String,Object> getPayload()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the custom payload from document metadata.

      This is a convenience method that delegates to the metadata's getPayload(). The payload contains business-specific fields such as filename, department, author, tags, and other custom metadata.

      返回:
      an unmodifiable map of custom metadata fields (never null)
    • getPayloadValue

      public Object getPayloadValue(String key)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets a specific payload value by key.

      This is a convenience method that delegates to the metadata's getPayloadValue(). Use this to retrieve individual payload values without accessing the entire map.

      参数:
      key - the payload key
      返回:
      the payload value, or null if the key doesn't exist
      抛出:
      NullPointerException - if key is null
    • getPayloadValueAs

      public <T> T getPayloadValueAs(String key, Class<T> targetClass)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets a specific payload value by key and converts it to the specified type.

      This method is useful when the payload contains complex objects (like custom POJOs) that were serialized to Map during storage. It uses Jackson's ObjectMapper to convert the Map back to the original type.

      类型参数:
      T - the target type
      参数:
      key - the payload key
      targetClass - the target class to convert to
      返回:
      the payload value converted to the specified type, or null if the key doesn't exist
      抛出:
      IllegalArgumentException - if the value cannot be converted to the target type
      NullPointerException - if key or clazz is null
    • hasPayloadKey

      public boolean hasPayloadKey(String key)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Checks if the document payload contains a specific key.

      This is a convenience method that delegates to the metadata's hasPayloadKey(). Use this to safely check for the existence of a payload field before retrieving it.

      参数:
      key - the payload key to check
      返回:
      true if the key exists in the payload, false otherwise
      抛出:
      NullPointerException - if key is null
    • getVectorName

      public String getVectorName()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Gets the document vector name.
      返回:
      the document name, or null if not set
    • setVectorName

      public void setVectorName(String vectorName)
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      Sets the document vector name.
      参数:
      vectorName - the document name
    • toString

      public String toString()
      已过时, 待删除: 此 API 元素将从以后的版本中删除。
      覆盖:
      toString 在类中 Object