註
Azure AI 搜尋服務 可透過 Azure 入口網站、REST API 及 Azure SDK 取得。 它同時也是 Foundry IQ 的基礎,這是一個管理式知識層,能將企業內容轉化為可重複使用、權限感知的知識庫,供 Microsoft Foundry 入口網站中的代理使用。
Important
標記(預覽)的功能、能力或屬性不受服務等級協議涵蓋,也不建議用於生產工作負載,且在正式上架前可能會有所變動或受限。 Azure AI 搜尋服務 預覽條款適用於所有預覽功能,無論是獨立功能還是正式推出功能的一部分。
已建立索引的 OneLake 知識來源會將 Microsoft OneLake 檔案匯入 Azure AI 搜尋服務 中的代理式擷取管線。 知識來源 獨立建立,並在 知識庫中被引用,並在 執行時查詢知識庫時作為基礎資料。
當你建立索引化的 OneLake 知識來源時,請指定一個外部資料來源、模型和屬性,以自動產生以下 Azure AI 搜尋服務 物件:
- 代表湖存放庫的資料來源。
- 一套技能集,可以將 Lakehouse 的多模態內容分割並選擇性地向量化。
- 一個儲存豐富內容且符合代理檢索標準的索引。
- 使用先前物件來驅動編製索引和擴充管線的索引子。
生成的索引器符合 OneLake 索引器的標準,其前置條件、支援任務、支援的文件格式、支援的捷徑及限制也適用於 OneLake 的知識來源。 欲了解更多資訊,請參閱 OneLake 索引器文件 及 索引器限制。 若所產生的技能組呼叫外部服務,該技能的輸入與服務限制也會適用。
使用支援
| Azure portal | Microsoft Foundry 入口 | .NET SDK | Python SDK | Java 開發套件 | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
先決條件
任何 區域內提供主動檢索的 Azure AI 搜尋服務 服務。
完成 OneLake 索引器的先決條件。
完成 OneLake 索引器資料準備。
如果
contentExtractionMode是standard,請使用位於 Foundry Tools 中 Content Understanding 支援的區域 的 Microsoft Foundry 資源,以及https://<resource-name>.services.ai.azure.com端點。 部署嵌入模型,若啟用影像語言化,則部署多模態聊天模型。允許建立知識來源。 建議使用分配給你的使用者帳號的搜尋服務貢獻者和搜尋索引資料貢獻者角色來設定無密鑰認證,或使用管理員 API 金鑰。
若知識來源指定 Azure OpenAI 模型用於嵌入或影像文字化,搜尋服務必須具有 受控識別,且在 Microsoft Foundry 資源上具有 Cognitive Services User 權限。
必備的
Azure.Search.Documents套件:關於
2026-08-01-preview功能,最新預覽包:dotnet add package Azure.Search.Documents --prerelease針對
2026-04-01功能,最新穩定版本套件:dotnet add package Azure.Search.Documents
對於無鑰匙認證,套件如下
Azure.Identity:dotnet add package Azure.Identity
必備的
azure-search-documents套件:關於
2026-08-01-preview功能,最新預覽包:pip install --pre azure-search-documents針對
2026-04-01功能,最新穩定版本套件:pip install azure-search-documents
對於無鑰匙認證,套件如下
azure-identity:pip install azure-identity
必要的搜尋服務 REST API 版本:
預覽功能: 2026-08-01-preview
適用於正式運作的功能:2026-04-01
對於無金鑰認證,請在
Authorization每個 HTTP 請求的標頭中加入 Microsoft Entra ID 令牌。
限制
索引 OneLake 知識來源不支援私有同步。 保持 networkAccessMode 設定為 public。
檢查現有的知識來源
知識來源是一個頂層且可重複使用的物件。 了解現有的知識來源對於重用或命名新物件都很有幫助。
執行以下程式碼,依名稱和類型列出知識來源。
// List knowledge sources by name and type
using Azure.Search.Documents.Indexes;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential);
var knowledgeSources = indexClient.GetKnowledgeSourcesAsync();
Console.WriteLine("Knowledge Sources:");
await foreach (var ks in knowledgeSources)
{
Console.WriteLine($" Name: {ks.Name}, Type: {ks.GetType().Name}");
}
參考資料:SearchIndexClient
# List knowledge sources by name and type
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key"))
for ks in index_client.list_knowledge_sources():
print(f" - {ks.name} ({ks.kind})")
參考資料:SearchIndexClient
### List knowledge sources by name and type
GET {{search-url}}/knowledgesources?api-version={{api-version}}&$select=name,kind
Authorization: Bearer {{token}}
參考資料:知識來源列表
你也可以以名稱回傳單一知識來源,以檢視其 JSON 定義。
using Azure.Search.Documents.Indexes;
using System.Text.Json;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential);
// Specify the knowledge source name to retrieve
string ksNameToGet = "earth-knowledge-source";
// Get its definition
var knowledgeSourceResponse = await indexClient.GetKnowledgeSourceAsync(ksNameToGet);
var ks = knowledgeSourceResponse.Value;
// Serialize to JSON for display
var jsonOptions = new JsonSerializerOptions
{
WriteIndented = true,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
};
Console.WriteLine(JsonSerializer.Serialize(ks, ks.GetType(), jsonOptions));
參考資料:SearchIndexClient
# Get a knowledge source definition
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
import json
index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key"))
ks = index_client.get_knowledge_source("knowledge_source_name")
print(json.dumps(ks.as_dict(), indent = 2))
參考資料:SearchIndexClient
### Get a knowledge source definition
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}}
Authorization: Bearer {{token}}
參考資料:知識來源 - 取得
以下 JSON 是一個針對索引 OneLake 知識來源的範例回應。
{
"name": "my-onelake-ks",
"kind": "indexedOneLake",
"description": "A sample indexed OneLake knowledge source.",
"encryptionKey": null,
"indexedOneLakeParameters": {
"fabricWorkspaceId": "<REDACTED>",
"lakehouseId": "<REDACTED>",
"targetPath": null,
"ingestionParameters": {
"disableImageVerbalization": false,
"ingestionPermissionOptions": [],
"contentExtractionMode": "standard",
"identity": null,
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<REDACTED>",
"deploymentId": "text-embedding-3-large",
"modelName": "text-embedding-3-large"
}
},
"chatCompletionModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<aoai-endpoint>",
"deploymentId": "gpt-5-mini",
"modelName": "gpt-5-mini"
}
},
"ingestionSchedule": null,
"aiServices": {
"uri": "<aoai-endpoint>",
}
},
"createdResources": {
"datasource": "my-onelake-ks-datasource",
"indexer": "my-onelake-ks-indexer",
"skillset": "my-onelake-ks-skillset",
"index": "my-onelake-ks-index"
}
}
}
建立知識來源
執行以下程式碼建立一個索引的 OneLake 知識來源。
// Create an indexed OneLake knowledge source
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.KnowledgeBases.Models;
using Azure.Search.Documents.Models;
using Azure.Identity;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), new DefaultAzureCredential());
var chatCompletionParams = new AzureOpenAIVectorizerParameters
{
ResourceUri = new Uri(aoaiEndpoint),
DeploymentName = aoaiGptDeployment,
ModelName = aoaiGptModel
};
var embeddingParams = new AzureOpenAIVectorizerParameters
{
ResourceUri = new Uri(aoaiEndpoint),
DeploymentName = aoaiEmbeddingDeployment,
ModelName = aoaiEmbeddingModel
};
var ingestionParams = new KnowledgeSourceIngestionParameters
{
NetworkAccessMode = KnowledgeSourceNetworkAccessMode.Public,
DisableImageVerbalization = false,
ChatCompletionModel = new KnowledgeBaseAzureOpenAIModel(azureOpenAIParameters: chatCompletionParams),
EmbeddingModel = new KnowledgeSourceAzureOpenAIVectorizer
{
AzureOpenAIParameters = embeddingParams
},
IngestionPermissionOptions = new List<KnowledgeSourceIngestionPermissionOption>
{
KnowledgeSourceIngestionPermissionOption.UserIds,
KnowledgeSourceIngestionPermissionOption.GroupIds
}
};
var oneLakeParams = new IndexedOneLakeKnowledgeSourceParameters(
fabricWorkspaceId: fabricWorkspaceId,
lakehouseId: lakehouseId)
{
IngestionParameters = ingestionParams
};
var knowledgeSource = new IndexedOneLakeKnowledgeSource(
name: "my-onelake-ks",
indexedOneLakeParameters: oneLakeParams)
{
Description = "This knowledge source pulls content from a lakehouse."
};
await indexClient.CreateOrUpdateKnowledgeSourceAsync(knowledgeSource);
Console.WriteLine($"Knowledge source '{knowledgeSource.Name}' created or updated successfully.");
# Create an indexed OneLake knowledge source
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import IndexedOneLakeKnowledgeSource, IndexedOneLakeKnowledgeSourceParameters, KnowledgeBaseAzureOpenAIModel, AzureOpenAIVectorizerParameters, KnowledgeSourceAzureOpenAIVectorizer, KnowledgeSourceContentExtractionMode, KnowledgeSourceIngestionParameters
from azure.search.documents.knowledgebases.models import KnowledgeSourceNetworkAccessMode
index_client = SearchIndexClient(endpoint = "<search-endpoint>", credential = DefaultAzureCredential())
knowledge_source = IndexedOneLakeKnowledgeSource(
name = "my-onelake-ks",
description= "This knowledge source pulls content from a lakehouse.",
encryption_key = None,
indexed_one_lake_parameters = IndexedOneLakeKnowledgeSourceParameters(
fabric_workspace_id = "fabric_workspace_id",
lakehouse_id = "lakehouse_id",
target_path = None,
ingestion_parameters = KnowledgeSourceIngestionParameters(
network_access_mode = KnowledgeSourceNetworkAccessMode.PUBLIC,
identity = None,
disable_image_verbalization = False,
chat_completion_model = KnowledgeBaseAzureOpenAIModel(
azure_open_ai_parameters = AzureOpenAIVectorizerParameters(
resource_url = "<aoai-endpoint>",
deployment_name = "<aoai-gpt-deployment>",
model_name = "<aoai-gpt-model>",
)
),
embedding_model = KnowledgeSourceAzureOpenAIVectorizer(
azure_open_ai_parameters=AzureOpenAIVectorizerParameters(
resource_url = "<aoai-endpoint>",
deployment_name = "<aoai-embedding-deployment>",
model_name = "<aoai-embedding-model>",
)
),
content_extraction_mode = KnowledgeSourceContentExtractionMode.MINIMAL,
ingestion_schedule = None,
ingestion_permission_options = ["user_ids", "group_ids"]
)
)
)
index_client.create_or_update_knowledge_source(knowledge_source)
print(f"Knowledge source '{knowledge_source.name}' created or updated successfully.")
參考資料:SearchIndexClient
### Create an indexed OneLake knowledge source
PUT {{search-endpoint}}/knowledgesources/my-onelake-ks?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
Content-Type: application/json
{
"name": "my-onelake-ks",
"kind": "indexedOneLake",
"description": "This knowledge source pulls content from a lakehouse.",
"indexedOneLakeParameters": {
"fabricWorkspaceId": "<fabric-workspace-id>",
"lakehouseId": "<lakehouse-id>",
"targetPath": null,
"ingestionParameters": {
"networkAccessMode": "public",
"identity": null,
"disableImageVerbalization": null,
"chatCompletionModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "{{aoai-gpt-deployment}}",
"modelName": "{{aoai-gpt-model}}"
}
},
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "{{aoai-embedding-deployment}}",
"modelName": "{{aoai-embedding-model}}"
}
},
"contentExtractionMode": "minimal",
"ingestionSchedule": null,
"ingestionPermissionOptions": ["userIds", "groupIds"]
}
}
}
參考資料:知識來源 - 建立或更新
註
若要使用 ingestionPermissionOptions 強制執行文件層級權限,請使用 2026-08-01-preview API 版本。 2026-04-01 的 API 版本不支援此功能。
使用自動語言分析器(預覽)
自 2026-08-01-preview API 版本起,Blob、已建立索引的 OneLake,以及已建立索引的 SharePoint 知識來源可使用每種語言的自動分析器。 啟用後,Azure AI 搜尋服務 會偵測每個來源文件的語言,並自動套用對應的 Microsoft 語言分析器。 你不會在知識來源定義或查詢中指定分析器。
若要啟用各語言的自動分析器,請將 contentExtractionMode 設為 minimal,並在知識來源定義中設定 ingestionParameters.aiServices。
對於無金鑰驗證,省略aiServices.apiKey並將 Microsoft Foundry 資源中的認知服務使用者角色指派到搜尋服務的管理身份上。 對於基於金鑰的認證,請設定 aiServices.apiKey 為 Foundry 資源的有效金鑰。
支援下列語言:
- English
- 日本
- 法語
- 西班牙語
- 德語
- 荷蘭語
- 義大利語
- 巴西葡萄牙文
- 歐洲葡萄牙語
- 簡體中文
- 繁體中文
- 韓語
對於多語言內容,Azure AI 搜尋服務 會根據主要偵測語言選擇分析器。 當語言不支援或不確定時,它會使用標準分析器。
當你啟用自動的語言分析器時,Azure AI 搜尋服務 會在產生的索引架構中加入每種支援語言的語言專屬內容欄位,無論你的資料是否包含該語言的文件。 在擷取過程中,文件會根據偵測到的語言被導向到相應的語言專屬欄位。
未使用的語言欄位不包含索引內容,且對儲存的影響極小,但仍屬於索引結構,並計入索引欄位的限制。 規劃索引設計、欄位數量及儲存需求時,請考慮額外的欄位。 欲了解更多資訊,請參閱 索引限制 及 搜尋服務容量估算與管理。
語言偵測在免費 AI 擴充配額用完後將開始收費。 欲了解更多資訊,請參閱 免費豐富活動。
檢查吞食狀態
執行下列程式碼以監視擷取進度和健康情況,包括知識來源種類,以及產生索引子管線並填入搜尋索引之知識來源的詳細索引錯誤。
using Azure.Search.Documents.Indexes;
using System.Text.Json;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), new AzureKeyCredential(apiKey));
// Get knowledge source ingestion status
var statusResponse = await indexClient.GetKnowledgeSourceStatusAsync(knowledgeSourceName);
var status = statusResponse.Value;
// Serialize to JSON for display
var json = JsonSerializer.Serialize(status, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(json);
參考資料:SearchIndexClient
# Check knowledge source ingestion status
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
import json
index_client = SearchIndexClient(endpoint="search_url", credential=AzureKeyCredential("api_key"))
status = index_client.get_knowledge_source_status("knowledge_source_name")
print(json.dumps(status.as_dict(), indent=2))
參考資料:SearchIndexClient
### Check knowledge source ingestion status
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}/status?api-version={{api-version}}
Authorization: Bearer {{token}}
Content-Type: application/json
參考資料:知識來源 - 取得狀態
包含輸入參數並且正在積極匯入內容的請求回應,其格式可能如以下範例。
{
"kind": "azureBlob",
"synchronizationStatus": "active",
"synchronizationInterval": "1d",
"currentSynchronizationState": {
"startTime": "2026-04-10T19:30:00Z",
"itemUpdatesProcessed": 1100,
"itemsUpdatesFailed": 100,
"itemsSkipped": 1100,
"errors": [
{
"key": "Item id 1",
"docURL": "https://contoso.blob.core.windows.net/contracts/2024/Q4/doc-00023.csv",
"statusCode": 400,
"componentName": "DocumentExtraction.AzureBlob.MyDataSource",
"errorMessage": "Could not read the value of column 'foo' at index '0'.",
"details": "The file could not be parsed.",
"documentationLink": "https://go.microsoft.com/fwlink/?linkid=2049388"
}
]
},
"lastSynchronizationState": {
"status": "partialSuccess",
"startTime": "2026-04-09T19:30:00Z",
"endTime": "2026-04-09T19:40:01Z",
"itemUpdatesProcessed": 1100,
"itemsUpdatesFailed": 100,
"itemsSkipped": 1100,
"errors": null
},
"statistics": {
"totalSynchronizations": 25,
"averageSynchronizationDuration": "00:15:20",
"averageItemsProcessedPerSynchronization": 500
}
}
註
kind屬性和currentSynchronizationState.errors[]陣列提供文件層級錯誤細節,並自 2026-04-01 起於 API 版本中提供。 對於較早期的 API 版本,這些欄位不會回傳。
lastSynchronizationState.status這個欄位也是在 2026-04-01 新增的。
檢視產生的物件
當你建立這個知識來源時,Azure AI 搜尋服務 會自動產生資料來源、技能集、索引器和索引。 建立回應會列出 createdResources 下的每個物件。
這些物件依據固定模板產生,名稱則取自知識來源的名稱。 你無法更改物件名稱。 避免直接編輯這些物件,因為變更可能會產生錯誤或不相容,破壞索引器管線。
你可以使用 Azure 入口網站來驗證物件建立。 工作流程如下:
檢查索引器上的成功或失敗訊息。 連線或配額錯誤會出現在這裡。
請檢查資料來源以確認與資料儲存的連結。 連線會依據您設定知識來源的方式,使用連接字串或受控識別。
檢查技能組,了解系統如何將你的內容分塊,以及是否選擇性地進行向量化。
檢查索引,了解你的內容如何被索引並展示以便檢索,包括哪些欄位可搜尋和篩選,哪些欄位儲存向量以便相似度搜尋。 使用搜尋總管對產生的索引執行查詢。
指派至知識庫
如果你對知識來源感到滿意,就 把它加入知識庫。
對於任何指定索引 OneLake 知識來源的知識庫,請務必設定 includeReferenceSourceData 為 true。 此步驟是將原始文件網址拉入引用中所必需的。
查詢知識庫
設定知識庫後, 呼叫擷取動作或 MCP 端點 查詢知識來源。 選擇符合你情境的配置。
強制執行文件層級權限 (預覽版)
若要強制執行文件層級權限,請在建立此知識來源時設定 ingestionPermissionOptions,然後在擷取要求中包含使用者的存取權杖。 更多資訊請參閱查詢時強制執行權限(預覽)。
Surface 文件內嵌影像(預覽)
要在答案綜合回應中呈現文件嵌入的影像(如圖表或掃描圖),請在此知識來源上設定 assetStore ,然後在知識庫啟用影像服務。 設定時 ingestionPermissionOptions 不支援影像服務。 如需詳細資訊,請參閱 在 agentic retrieval 中呈現文件內嵌影像(預覽)。
刪除知識來源
在刪除知識來源之前,必須刪除所有引用該來源的知識庫,或更新知識庫定義以移除該參考。 對於產生索引與索引管線的知識來源,所有 產生的物件 也會被刪除。 不過,如果你用現有的索引建立知識來源,你的索引不會被刪除。
如果你嘗試刪除正在使用的知識來源,該動作會失敗,並回傳一份受影響的知識庫清單。
刪除知識來源:
取得你搜尋服務中所有知識庫的清單。
using Azure.Search.Documents.Indexes; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); var knowledgeBases = indexClient.GetKnowledgeBasesAsync(); Console.WriteLine("Knowledge Bases:"); await foreach (var kb in knowledgeBases) { Console.WriteLine($" - {kb.Name}"); }參考資料:SearchIndexClient
一個範例回應可能如下:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }取得一個獨立的知識庫定義,以檢查是否有知識來源的參考。
using Azure.Search.Documents.Indexes; using System.Text.Json; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); // Specify the knowledge base name to retrieve string kbNameToGet = "earth-knowledge-base"; // Get a specific knowledge base definition var knowledgeBaseResponse = await indexClient.GetKnowledgeBaseAsync(kbNameToGet); var kb = knowledgeBaseResponse.Value; // Serialize to JSON for display string json = JsonSerializer.Serialize(kb, new JsonSerializerOptions { WriteIndented = true }); Console.WriteLine(json);參考資料:SearchIndexClient
一個範例回應可能如下:
{ "Name": "earth-knowledge-base", "KnowledgeSources": [ { "Name": "earth-knowledge-source" } ], "Models": [ {} ], "RetrievalReasoningEffort": {}, "OutputMode": {}, "ETag": "\u00220x8DE278629D782B3\u0022", "EncryptionKey": null, "Description": null, "RetrievalInstructions": null, "AnswerInstructions": null }要麼刪除知識庫,要麼如果你有多個知識來源,就更新知識庫來移除該來源。 這個例子顯示刪除。
using Azure.Search.Documents.Indexes; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); await indexClient.DeleteKnowledgeBaseAsync(knowledgeBaseName); System.Console.WriteLine($"Knowledge base '{knowledgeBaseName}' deleted successfully.");參考資料:SearchIndexClient
刪除知識來源。
await indexClient.DeleteKnowledgeSourceAsync(knowledgeSourceName); System.Console.WriteLine($"Knowledge source '{knowledgeSourceName}' deleted successfully.");參考資料:SearchIndexClient
取得你搜尋服務中所有知識庫的清單。
# Get knowledge bases from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) print("Knowledge Bases:") for kb in index_client.list_knowledge_bases(): print(f" - {kb.name}")參考資料:SearchIndexClient
一個範例回應可能如下:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }取得一個獨立的知識庫定義,以檢查是否有知識來源的參考。
# Get a knowledge base definition from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) kb = index_client.get_knowledge_base("knowledge_base_name") print(kb)參考資料:SearchIndexClient
一個範例回應可能如下:
{ "name": "my-kb", "description": null, "retrievalInstructions": null, "answerInstructions": null, "outputMode": null, "knowledgeSources": [ { "name": "my-blob-ks" } ], "models": [], "encryptionKey": null, "retrievalReasoningEffort": { "kind": "low" } }要麼刪除知識庫,要麼如果你有多個知識來源,就更新知識庫來移除該來源。 這個例子顯示刪除。
# Delete a knowledge base from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) index_client.delete_knowledge_base("knowledge_base_name") print(f"Knowledge base deleted successfully.")參考資料:SearchIndexClient
刪除知識來源。
# Delete a knowledge source from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) index_client.delete_knowledge_source("knowledge_source_name") print(f"Knowledge source deleted successfully.")參考資料:SearchIndexClient
取得你搜尋服務中所有知識庫的清單。
### Get knowledge bases GET {{search-url}}/knowledgebases?api-version={{api-version}}&$select=name Authorization: Bearer {{token}}參考資料:知識庫列表
一個範例回應可能如下:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }取得一個獨立的知識庫定義,以檢查是否有知識來源的參考。
### Get a knowledge base definition GET {{search-url}}/knowledgebases/{{knowledge-base-name}}?api-version={{api-version}} Authorization: Bearer {{token}}參考資料:知識庫 - 取得
一個範例回應可能如下:
{ "name": "my-kb", "description": null, "retrievalInstructions": null, "answerInstructions": null, "outputMode": null, "knowledgeSources": [ { "name": "my-blob-ks" } ], "models": [], "encryptionKey": null, "retrievalReasoningEffort": { "kind": "low" } }要麼刪除知識庫,要麼如果你有多個知識來源,就更新知識庫來移除該來源。 這個例子顯示刪除。
### Delete a knowledge base DELETE {{search-url}}/knowledgebases/{{knowledge-base-name}}?api-version={{api-version}} Authorization: Bearer {{token}}參考資料:知識庫 - 刪除
刪除知識來源。
### Delete a knowledge source DELETE {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}} Authorization: Bearer {{token}}參考資料:知識來源 - 刪除