全部產品
Search
文件中心

Data Management:RetrieveKnowledgeBase - 檢索知識庫

更新時間:Jun 10, 2026

檢索知識庫

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

當前API暫無授權資訊透出。

請求參數

名稱

類型

必填

描述

樣本值

KbUuid

string

知識庫 ID。

kb-***

Query

string

查詢內容。

What is GraphRAG?

TopK

integer

返回 top 數量的結果。

10

Filter

string

要查詢的資料的過濾條件,格式為 SQL 的 WHERE 格式。

title = 'test' AND name like 'test%'

Metrics

string

檢索時的相似性演算法。此值為空白時則採用建立知識庫時指定的演算法,建議如無特殊需求不需設定。

可選值:

  • l2:歐氏距離。

  • ip:點積(內積)距離。

  • cosine:餘弦相似性。

cosine

HybridSearch

string

多路召回演算法,預設為空白(即直接將稠密向量和全文的分數比較並排序)。

可選值:

  • RRF:倒數排序融合(Reciprocal rank fusion),有一個參數 k 控制融合效果,詳見 HybridSearchArgs 配置。

  • Weight:比重排序,採用參數控制向量和全文的分數比重,然後再排序,參數詳見 HybridSearchArgs 配置。

  • Cascaded:先全文檢索索引再在其基礎上進行向量檢索。

RRF

HybridSearchArgs

string

多路召回的演算法參數。目前支援 RRF 和 Weight 兩種。HybridPathsSetting 可以指定召回稠密向量(dense)、稀疏向量(sparse)和全文檢索索引(fulltext),如果值為空白,預設召回稠密向量(dense)和全文檢索索引(fulltext)。

  • RRF:指定計算分數的演算法的1/(k+rank_i)中的 k 常數,範圍大於 1 的正整數,格式為:

{
  "HybridPathsSetting": {
    "paths": "dense,fulltext"
  },
  "RRF": {
    "k": 60
  }
}
  • Weight:
    • 雙路召回(不指定 HybridPathsSetting,僅指定 alpha):
      • 計算公式:alpha * dense_score + (1-alpha) * fulltext_score,參數 alpha 表示稠密向量和全文的檢索分數比重,範圍為 0~1,其中 0 表示只全文,1 表示只稠密向量:

{ 
   "Weight": {
    "alpha": 0.5
   }
}
  • 三路召回模式:
    • 計算公式:normalized_dense * dense_score + normalized_sparse * sparse_score + normalized_fulltext * fulltext_score。其中 dense、sparse、fulltext 分別代表稠密向量、稀疏向量、全文檢索索引的權重,取值範圍大於等於 0。系統會自動將權重歸一化到 0~1(即 normalized_x = x / (dense + sparse + fulltext))。

{
  "HybridPathsSetting": {
     "paths": "dense,sparse,fulltext"
   },
  "Weight": {
    "dense": 0.5,
    "sparse": 0.3,
    "fulltext": 0.2
  }
}

{ \"Weight\": { \"alpha\": 0.5 } }

IncludeVector

boolean

是否返迴向量。預設為 false。

說明
  • false:不返迴向量。

  • true:返迴向量。

false

IncludeMetadataFields

string

預設為空白,表示要返回的 metadata 欄位,多個欄位用逗號分隔。

title,page

RerankFactor

number

重排因子。當該值不為空白時,會對向量檢索結果再做一次重排。取值範圍:1<RerankFactor<=5。

說明
  • 當文檔切分稀疏時,重排效率慢。

  • 建議重排個數(TopK*Factor(向上取整))不超過 50。

2

RecallWindow

string

召回視窗。當該值不為空白時,增加返回檢索結果的上下文。格式為 2 個元素的數組:List<A, B>,其中-10<=A<=0,0<=B<=10。

說明
  • 推薦當文檔切分過碎、檢索可能會丟失上下文資訊時使用該參數。

  • 重排優先視窗化,即先 rerank,再視窗化處理。

[-5,5]

OrderBy

string

預設為空白,表示排序的依據欄位。

欄位必須屬於 metadata 或表裡的預設欄位比如 id,格式支援:

單個欄位,如 chunk_id; 多個欄位,用逗號串連,如 block_id, chunk_id; 支援反序,如: block_id DESC, chunk_id DESC;

created_at

Offset

integer

位移量,用於分頁查詢

0

返回參數

名稱

類型

描述

樣本值

object

Schema of Response

RequestId

string

本次調用的唯一 ID。出現錯誤後,您可以根據該 ID 排查問題。

67E910F2-4B62-5B0C-ACA3-7547695C****

Data

object

返回結構體。

Results

array<object>

結果清單。

array<object>

返回資料。

Id

string

向量資料的唯一 Id。

3b35c95-57f3-442f-9220-xxxxx

Content

string

常值內容。

GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.

FileName

string

文檔名稱。

1.txt

LoaderMetadata

string

文檔載入器載入時的元資訊。

{"page_pos": 1}

Score

number

此條資料的相似性分數,其分數演算法和建立索引時指定的演算法(l2/ip/cosine)相關。

0.81

Vector

array

向量資料列表。

number

向量資料。

1.2123

Metadata

object

中繼資料 Map。

{"title":"test"}

RerankScore

number

重排分數。

6.2345

RetrievalSource

integer

檢索結果的來源。1 表示向量檢索,2 表示全文檢索索引,3 表示雙路召回。

1

Matches

array<object>

視窗化匹配到的列表。

array<object>

返回資料。

Content

string

常值內容。

GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.

FileName

string

文檔名稱。

1.txt

Id

string

向量資料的唯一 Id。

3b35c95-57f3-442f-9220-xxxxx

LoaderMetadata

string

文檔載入器載入時的元資訊。

{"page_pos": 1}

Metadata

object

中繼資料 Map。

{"title":"test"}

ErrorCode

string

錯誤碼,請求異常時返回。

KnowledgeBaseNotFound

Success

boolean

請求是否成功,傳回值如下:

  • true:請求成功。

  • false:請求失敗。

true

ErrorMessage

string

調用失敗時,返回的錯誤資訊。

Resource not found kb-***

樣本

正常返回樣本

JSON格式

{
  "RequestId": "67E910F2-4B62-5B0C-ACA3-7547695C****",
  "Data": {
    "Results": [
      {
        "Id": "3b35c95-57f3-442f-9220-xxxxx",
        "Content": "GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.",
        "FileName": "1.txt",
        "LoaderMetadata": "{\"page_pos\": 1}",
        "Score": 0.81,
        "Vector": [
          1.2123
        ],
        "Metadata": {
          "title": "test"
        },
        "RerankScore": 6.2345,
        "RetrievalSource": 1
      }
    ],
    "Matches": [
      {
        "Content": "GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.",
        "FileName": "1.txt",
        "Id": "3b35c95-57f3-442f-9220-xxxxx",
        "LoaderMetadata": "{\"page_pos\": 1}",
        "Metadata": {
          "title": "test"
        }
      }
    ]
  },
  "ErrorCode": "KnowledgeBaseNotFound",
  "Success": true,
  "ErrorMessage": "Resource not found kb-***"
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情