Skip to main content

RecallDocument

You can retrieve document chunks from a document library using text. You can specify the number of chunks to retrieve, filter them by metadata conditions, and choose whether to complete the document chunks.

Operation description

Prerequisites
  • Activate the Alibaba Cloud Model Studio service and the Tongyi Dianjin service.
  • Obtain the workspace ID. Obtain the workspace identity.

Try it now

You can run this API directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After a successful run, OpenAPI Explorer can automatically generate SDK code examples. Debug

RAM authorization

The following table describes the authorization information for this API. You can use it in the Action element of a RAM policy statement to grant RAM users or RAM roles the permission to call this API. For more information:
  • Action: the specific permission point.
  • Access level: the access level of each action. Valid values: Write, Read, and List.
  • Resource type: the resource types that support authorization for the action. Details:
    • Required resource types are marked with a preceding asterisk (*).
    • For operations that do not support resource-level authorization, All resources is used.
  • Condition key: the condition keys defined by the cloud service itself.
  • Dependent action: the other permissions required to successfully perform the operation. The caller must also have the permissions of the dependent actions for the operation to succeed.
ActionAccess levelResource typeCondition keyDependent action
dianjin:RecallDocumentnone
*All resources
*
    None
None

Request syntax

POST /{workspaceId}/api/library/recallDocument HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample value
workspaceIdstringYes

Path parameter, workspace ID.

llm-xxxxx
bodyobjectNo

Request body parameters.

filtersarray<object>No

Metadata filter conditions.

filterobjectNo

Filter.

andarray<object>No

AND expression, used to filter documents/document chunks.

andobjectNo

AND expression.

boostfloatNo

Keyword weight.

20
keystringNo

The key of the metadata in the document library.

docType
operatorstringNo

The relationship between the value stored in the document library metadata key and the value you enter.

  • eq: The value stored in the document library metadata key equals the value you enter.
  • lte: The value stored in the document library metadata key is less than or equal to the value you enter.
  • gte: The value stored in the document library metadata key is greater than or equal to the value you enter.
  • lt: The value stored in the document library metadata key is less than the value you enter.
  • gt: The value stored in the document library metadata key is greater than the value you enter.
  • contains: The list of values stored in the document library metadata key contains the value you enter.
contains
valuestringNo

The value of the metadata you enter.

Strategy report
chunkTypestringNo

Document chunk type, used to filter document chunks, including: Text, Graph, Table, FAQ.

Text
docIdListarrayNo

Document ID list, used to filter documents/document chunks.

docIdListstringNo

Document ID.

8372458573692819933
libraryIdstringYes

Document library ID, used to filter documents/document chunks.

sdbjhvs
orarray<object>No

OR expression, used to filter documents/document chunks.

orobjectNo

OR expression.

boostfloatNo

Keyword weight.

30
keystringNo

The key of the metadata in the document library.

researcher
operatorstringNo

The relationship between the value stored in the document library metadata key and the value you enter.

  • eq: The value stored in the document library metadata key equals the value you enter.
  • lte: The value stored in the document library metadata key is less than or equal to the value you enter.
  • gte: The value stored in the document library metadata key is greater than or equal to the value you enter.
  • lt: The value stored in the document library metadata key is less than the value you enter.
  • gt: The value stored in the document library metadata key is greater than the value you enter.
  • contains: The list of values stored in the document library metadata key contains the value you enter.
eq
valuestringNo

The value of the metadata you enter.

zhangsan
statusarrayNo

Document status list, used to filter documents.

statustringNo

Document status.

WaitRefresh
querystringYes

Text.

Which teams in European Championship history have benefited from players adapting to new cultures
rearrangementbooleanNo

Whether to enable parent-child document chunk recall.

  • Parent-child document chunks: During document parsing, a complete semantic block, such as a paragraph or a section, might be split into multiple document chunks, depending on your chunking strategy. After parent-child document chunk recall is enabled, the system attempts to complete the semantic block to which the retrieved document chunk belongs. This makes the corpus more semantically complete when constructing prompts, improving the completeness and accuracy of answers.
false
topKintegerNo

The number of document chunks to recall.

10

Response elements

ElementTypeDescriptionExample value
object

Returned data.

costlong

Time elapsed.

0
dataobject

Response data.

chunkListarray<object>

Chunk list.

chunkListobject

Chunk.

chunkIdstring

Document chunk ID.

823746762354
chunkMetaobject

Document chunk metadata.

{"a":"1"}
chunkOssUrlstring

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx
chunkTextstring

Document chunk text.

Test document chunk
chunkTypestring

Document chunk type.

text
docIdstring

Document ID.

839468263472
fileTypestring

Document type.

pdf
libraryIdstring

Document library ID.

dscsbdsk
libraryNamestring

Document library name.

Test document library
nextChunkIdstring

Next document chunk ID.

982374872364
posarray<object>

Document chunk position.

poobject

Document chunk position coordinates.

axisArrayarray

Coordinates.

axisArraydouble

Coordinate value.

20.8
pageinteger

Page number.

1
textHighlightAreaarray

Text highlight area, used for text-type file highlighting.

textHighlightAreainteger

Text highlight area data.

1
preChunkIdstring

Previous document chunk ID.

827364827364832
scorefloat

Document chunk score.

0.5
titlestring

Document title.

test
chunkPartListarray<object>

Chunk part (layout recognition result) list.

chunkPartListobject

Chunk part (layout recognition result).

chunkIdstring

Document chunk ID.

98327482364
chunkMetaobject

Document chunk metadata.

{"a":"1"}
chunkOssUrlstring

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx
chunkTextstring

Document chunk text.

Test document chunk
chunkTypestring

Document chunk type.

text
docIdstring

Document ID.

92837482364
fileTypestring

Document type.

pdf
libraryIdstring

Document library ID.

sjdhgjsd
libraryNamestring

Document library name.

Test document library
nextChunkIdstring

Next document chunk ID.

2387648263542
posarray<object>

Document chunk position.

poobject

Document chunk position data.

axisArrayarray

Coordinates.

axisArraydouble

Coordinate value.

1
pageinteger

Page number.

1
textHighlightAreaarray

Text highlight area, used for text-type file highlighting.

textHighlightAreainteger

Text highlight area position data.

1
preChunkIdstring

Previous document chunk ID.

32874682764
scorefloat

Document chunk score.

0.5
titlestring

Document title.

Test document title
chunkTextListarray

Chunk text list.

chunkTextListstring

Document chunk.

This is a test document chunk
documentsarray<object>

Document list.

documentobject

Document information.

docIdstring

Document ID.

92837482364
documentMetaobject

Document metadata.

{"a":"1"}
fileTypestring

Document type.

pdf
gmtCreatestring

Creation time.

2024-01-01 00:00:00
libraryIdstring

Document library ID.

sjdhgjsd
titlestring

Document title.

test
urlstring

Document link.

http://oss-xxx-hangzhou.com/test.pdf
embeddingElapsedMslong

Vector computation time elapsed.

100
textChunkListarray<object>

List of chunks retrieved from the text index.

textChunkListobject

Chunk retrieved from the text index.

chunkIdstring

Document chunk ID.

32874682364
chunkMetaobject

Document chunk metadata.

{"a":"1"}
chunkOssUrlstring

Document chunk OSS address.

http://oss-xxx-hangzhou.com/xxx
chunkTextstring

Document chunk text.

This is a test document chunk
chunkTypestring

Document chunk type.

text
docIdstring

Document ID.

8372467263542
fileTypestring

Document type.

pdf
libraryIdstring

Document library ID.

djsgfsjd
libraryNamestring

Document library name.

Test document library
nextChunkIdstring

Next document chunk ID.

23874682432
posarray<object>

Document chunk position.

poobject

Document chunk position.

axisArrayarray

Coordinates.

axisArraydouble

Coordinate value.

10
pageinteger

Page number.

1
textHighlightAreaarray

Text highlight area, used for text-type file highlighting.

textHighlightAreainteger

Text highlight area data.

1
preChunkIdstring

Previous document chunk ID.

89473868346
scorefloat

Document chunk score.

0.5
titlestring

Document title.

Test document title
textSearchElapsedMslong

Text search time elapsed.

100
totalElapsedMslong

Total time elapsed, including vector computation time, vector search time, and text search time (depending on retrieval parameters).

400
vectorChunkListarray<object>

List of chunks retrieved from the vector index.

vectorChunkListobject

Chunk retrieved from the vector index.

chunkIdstring

Document chunk ID.

8723642345276
chunkMetaobject

Document chunk metadata.

{"a":"1"}
chunkOssUrlstring

Document chunk OSS address.

https://oss-xxxx-hangzhou.com/test.pdf
chunkTextstring

Document chunk text.

This is a test text
chunkTypestring

Document chunk type.

text
docIdstring

Document ID.

78326476235675372
fileTypestring

Document type.

pdf
libraryIdstring

Document library ID.

djsgfsjd
libraryNamestring

Document library name.

Test document library
nextChunkIdstring

Next document chunk ID.

293846872343
posarray<object>

Document chunk position.

poobject

Document chunk position coordinates.

axisArrayarray

Coordinates.

axisArraydouble

Coordinate value.

48.8
pageinteger

Page number.

1
textHighlightAreaarray

Text highlight area, used for text-type file highlighting.

textHighlightAreainteger

Text highlight area.

10
preChunkIdstring

Previous document chunk ID.

873647326542
scorefloat

Document chunk score.

0.5
titlestring

Document title.

test
vectorSearchElapsedMslong

Vector search time elapsed.

100
dataTypestring

Data type.

null
errCodestring

Error code.

0
messagestring

Error message.

ok
requestIdstring

Request ID.

0bc13a9517168617617186457e401f
successboolean

Whether the request is successful.

true
timestring

Timestamp.

2024-04-24 11:54:34

Examples

Success response JSON format
{
  "cost": 0,
  "data": {
    "chunkList": [
      {
        "chunkId": 823746762354,
        "chunkMeta": {
          "a": 1
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx",
        "chunkText": "测试文档块",
        "chunkType": "text",
        "docId": 839468263472,
        "fileType": "pdf",
        "libraryId": "dscsbdsk",
        "libraryName": "测试文档库",
        "nextChunkId": 982374872364,
        "pos": [
          {
            "axisArray": [
              20.8
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": 827364827364832,
        "score": 0.5,
        "title": "test"
      }
    ],
    "chunkPartList": [
      {
        "chunkId": 98327482364,
        "chunkMeta": {
          "a": 1
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx\n",
        "chunkText": "测试文档块\n",
        "chunkType": "text",
        "docId": 92837482364,
        "fileType": "pdf",
        "libraryId": "sjdhgjsd",
        "libraryName": "测试文档库",
        "nextChunkId": 2387648263542,
        "pos": [
          {
            "axisArray": [
              1
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": 32874682764,
        "score": 0.5,
        "title": "测试文档标题"
      }
    ],
    "chunkTextList": [
      "这是一段测试文档块"
    ],
    "documents": [
      {
        "docId": 92837482364,
        "documentMeta": {
          "a": 1
        },
        "fileType": "pdf",
        "gmtCreate": "2024-01-01 00:00:00",
        "libraryId": "sjdhgjsd\n",
        "title": "test",
        "url": "http://oss-xxx-hangzhou.com/test.pdf"
      }
    ],
    "embeddingElapsedMs": 100,
    "textChunkList": [
      {
        "chunkId": 32874682364,
        "chunkMeta": {
          "a": 1
        },
        "chunkOssUrl": "http://oss-xxx-hangzhou.com/xxx\n",
        "chunkText": "这是一段测试文档块\n",
        "chunkType": "text",
        "docId": 8372467263542,
        "fileType": "pdf",
        "libraryId": "djsgfsjd",
        "libraryName": "测试文档库",
        "nextChunkId": 23874682432,
        "pos": [
          {
            "axisArray": [
              10
            ],
            "page": 1,
            "textHighlightArea": [
              1
            ]
          }
        ],
        "preChunkId": 89473868346,
        "score": 0.5,
        "title": "测试文档标题"
      }
    ],
    "textSearchElapsedMs": 100,
    "totalElapsedMs": 400,
    "vectorChunkList": [
      {
        "chunkId": 8723642345276,
        "chunkMeta": {
          "a": 1
        },
        "chunkOssUrl": "https://oss-xxxx-hangzhou.com/test.pdf",
        "chunkText": "这是一段测试文本",
        "chunkType": "text",
        "docId": 78326476235675380,
        "fileType": "pdf",
        "libraryId": "djsgfsjd",
        "libraryName": "测试文档库",
        "nextChunkId": 293846872343,
        "pos": [
          {
            "axisArray": [
              48.8
            ],
            "page": 1,
            "textHighlightArea": [
              10
            ]
          }
        ],
        "preChunkId": 873647326542,
        "score": 0.5,
        "title": "test"
      }
    ],
    "vectorSearchElapsedMs": 100
  },
  "dataType": null,
  "errCode": 0,
  "message": "ok",
  "requestId": "0bc13a9517168617617186457e401f",
  "success": true,
  "time": "2024-04-24 11:54:34"
}

Error codes

Visit the Error Center to view more error codes.