你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
注释
Azure AI 搜索可通过Azure门户、REST API 和Azure SDK获取。 它也是 Foundry IQ 的基础;Foundry IQ 是一个托管式知识层,可将企业内容转化为供 Microsoft Foundry 门户中的智能体使用的、可复用且具备权限感知能力的知识库。
Important
标记为“预览”的特性、功能或属性不受服务级别协议 (SLA) 保障,不建议用于生产工作负载,并且在正式发布之前可能会更改或受到限制。 Azure AI 搜索预览条款适用于所有预览功能,无论是独立功能还是正式版功能的一部分。
已编制索引的 Azure SQL 知识源(预览版)可将 Azure SQL 数据库 或 Azure SQL 托管实例 中的行数据引入 Azure AI 搜索 中的代理式检索管道。 知识库是在运行时查询知识库时独立创建的、在知识库中引用的,并用作基础数据。
与基于文件的知识源(如 Azure Blob 存储 和 OneLake)不同,每个 SQL 行都被视为一个逻辑文档。 通过显式列映射(而不是使用固定文档架构)驱动索引架构。
创建索引Azure SQL知识源时,可以指定 SQL 数据源、可选列映射和可选模型以自动生成以下Azure AI 搜索对象:
- 表示 SQL 表或视图的数据源。
- 一个索引,其字段根据您的列映射生成。
- 生成嵌入向量的技能集。 仅当指定
embeddingColumns时,服务才会创建技能集。 - 使用前述对象驱动数据引入管道的索引器。
生成的索引器符合 Azure SQL 索引器,其先决条件、更改检测策略和限制也适用于索引Azure SQL知识源。 有关详细信息,请参阅 Azure SQL 索引器文档。
使用支持
| Azure 门户 | Microsoft Foundry 门户 | .NET SDK | Python SDK | Java SDK | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
先决条件
在任意提供代理检索功能的区域中提供的 Azure AI 搜索服务。
完成 Azure SQL 索引器先决条件,包括:
一个包含可引入表或视图的 Azure SQL 数据库或 Azure SQL 托管实例。
源表或视图上的单值主键。
对于视图,适合用于高水位线更改检测的列。 强烈建议使用
rowversion列。
创建知识源的权限。 使用分配给用户帐户的搜索服务参与者和搜索索引数据参与者角色(建议)或使用管理员 API 密钥配置无密钥身份验证。
如果指定
embeddingColumns,搜索服务必须具有托管标识,并且该标识在托管嵌入模型的 Microsoft Foundry 资源上必须具有认知服务用户权限。如果将
networkAccessMode设置为private,请完成以下要求:使用
sqlServer组 ID 创建并批准指向 SQL 服务器的共享专用链接。 对于SQL 托管实例,请使用managedInstance组 ID。使用 SQL 身份验证或托管标识身份验证。 对于托管标识,请向该标识授予所需的 Azure 角色和数据库角色,并使用包含
Database=<database-name>以及 SQL server 或 SQL 托管实例 资源 ID 的连接字符串。 仅为用户分配的标识设置ingestionParameters.identity。 如果省略它,索引器将使用搜索服务的系统分配标识。为每个受保护的模型终结点创建和批准共享专用链接。 将
openai_account组 ID 用于 Azure OpenAI 终结点,将foundry_account用于 Foundry 资源终结点。
最新的
Azure.Search.Documents预览包:dotnet add package Azure.Search.Documents --prerelease对于无密钥身份验证,请使用
Azure.Identity软件包:dotnet add package Azure.Identity
最新的
azure-search-documents预览包:pip install --pre azure-search-documents对于无密钥身份验证,请使用
azure-identity软件包:pip install azure-identity
搜索服务 REST API 的 2026-08-01-preview 版本。
对于无密钥身份验证,请在每个 HTTP 请求的标头中包含
AuthorizationMicrosoft Entra ID令牌。
限制和注意事项
- 知识源只能从一个表或一个视图中引入数据。
- 源表或视图必须具有单值主键。 不支持复合键。
- 主键是自动发现的,无法重写。
-
contentExtractionMode仅支持"minimal"。 - 不支持图像提取和图像语言化。
- 不支持实时同步。 生成的索引器基于计划。
- 不支持实时 SQL 检索。 该知识来源已建立索引,而非远程源。
准备已生成的索引器
索引Azure SQL知识源会自动创建索引器来驱动引入。 在创建知识源之前,请查看以下详细信息。
变化检测
生成的索引器使用标准 Azure SQL 索引器更改检测:
表: 该服务会自动应用 SQL 集成更改跟踪 。 在创建知识源之前,请在源表上启用 SQL 更改跟踪 。
视图: 该服务应用高水位线更改检测。 指定要在
highWaterMarkColumn中使用的列。 强烈建议使用rowversion列。 若要检测视图中的删除,请在视图中包括软删除标记列,如 软删除列删除检测策略中所述。
身份验证
生成的索引器支持两种身份验证选项:
SQL authentication:在连接字符串中提供用户名和密码。
托管标识身份验证:使用系统分配或用户分配的托管标识,该标识在 SQL 资源上具有 Azure RBAC 和数据库级角色。
有关连接字符串格式、角色要求和设置步骤,请参阅 Azure SQL 索引器先决条件 和 通过托管标识进行连接。
检查现有知识源
知识源是顶级可重用对象。 了解现有知识源有助于重复使用或命名新对象。
运行以下代码,按名称和类型列出知识源。
// 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}");
}
Reference: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})")
Reference: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));
Reference: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))
Reference:SearchIndexClient
### Get a knowledge source definition
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}}
Authorization: Bearer {{token}}
参考:知识源 - 获取
以下 JSON 是索引Azure SQL知识源的示例响应。
{
"name": "indexedsqlks",
"kind": "indexedSql",
"description": "Sample indexed Azure SQL knowledge source.",
"encryptionKey": null,
"indexedSqlParameters": {
"connectionString": "<sql-connection-string>",
"tableOrView": "dbo.tbl_hotels",
"contentColumns": [
{ "name": "hotelName", "sourceField": "HotelName", "searchFieldType": "Edm.String" },
{ "name": "description", "sourceField": "Description", "searchFieldType": "Edm.String" }
],
"embeddingColumns": [
{ "name": "descriptionVector", "sourceField": "Description" }
],
"ingestionParameters": {
"contentExtractionMode": "minimal",
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<aoai-endpoint>",
"deploymentId": "text-embedding-3-large",
"modelName": "text-embedding-3-large"
}
},
"createdResources": {
"datasource": "indexedsqlks-datasource",
"indexer": "indexedsqlks-indexer",
"skillset": "indexedsqlks-skillset",
"index": "indexedsqlks-index"
}
}
}
}
创建知识源
运行以下代码以创建索引Azure SQL知识源。
using Azure.Identity;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.KnowledgeBases.Models;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), new DefaultAzureCredential());
var embeddingParams = new AzureOpenAIVectorizerParameters
{
ResourceUri = new Uri(aoaiEndpoint),
DeploymentName = aoaiEmbeddingDeployment,
ModelName = aoaiEmbeddingModel
};
var ingestionParams = new KnowledgeSourceIngestionParameters
{
NetworkAccessMode = KnowledgeSourceNetworkAccessMode.Public,
ContentExtractionMode = "minimal",
EmbeddingModel = new KnowledgeSourceAzureOpenAIVectorizer
{
AzureOpenAIParameters = embeddingParams
}
};
var sqlParams = new IndexedSqlKnowledgeSourceParameters(
connectionString: sqlConnectionString,
tableOrView: "dbo.tbl_hotels")
{
ContentColumns =
{
new ContentColumnMapping("hotelName", "HotelName", "Edm.String"),
new ContentColumnMapping("description", "Description", "Edm.String")
},
EmbeddingColumns =
{
new EmbeddingColumnMapping("descriptionVector", "Description")
},
IngestionParameters = ingestionParams
};
var knowledgeSource = new IndexedSqlKnowledgeSource(
name: "indexedsqlks",
indexedSqlParameters: sqlParams)
{
Description = "Indexed Azure SQL knowledge source."
};
await indexClient.CreateOrUpdateKnowledgeSourceAsync(knowledgeSource);
Console.WriteLine($"Knowledge source '{knowledgeSource.Name}' created or updated successfully.");
Reference:SearchIndexClient、 IndexedSqlKnowledgeSource
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
AzureOpenAIVectorizerParameters,
ContentColumnMapping,
EmbeddingColumnMapping,
IndexedSqlKnowledgeSource,
IndexedSqlKnowledgeSourceParameters,
)
from azure.search.documents.knowledgebases.models import (
KnowledgeSourceAzureOpenAIVectorizer,
KnowledgeSourceIngestionParameters,
KnowledgeSourceNetworkAccessMode,
)
index_client = SearchIndexClient(endpoint="<search-endpoint>", credential=DefaultAzureCredential())
embedding_params = AzureOpenAIVectorizerParameters(
resource_url="<aoai-endpoint>",
deployment_name="<aoai-embedding-deployment>",
model_name="<aoai-embedding-model>",
)
ingestion_params = KnowledgeSourceIngestionParameters(
network_access_mode=KnowledgeSourceNetworkAccessMode.PUBLIC,
content_extraction_mode="minimal",
embedding_model=KnowledgeSourceAzureOpenAIVectorizer(
azure_open_ai_parameters=embedding_params
),
)
knowledge_source = IndexedSqlKnowledgeSource(
name="indexedsqlks",
description="Indexed Azure SQL knowledge source.",
indexed_sql_parameters=IndexedSqlKnowledgeSourceParameters(
connection_string="Server=tcp:{server}.database.windows.net,1433;Database={db};...;",
table_or_view="dbo.tbl_hotels",
content_columns=[
ContentColumnMapping(
name="hotelName",
source_field="HotelName",
search_field_type="Edm.String",
),
ContentColumnMapping(
name="description",
source_field="Description",
search_field_type="Edm.String",
),
],
embedding_columns=[
EmbeddingColumnMapping(
name="descriptionVector",
source_field="Description",
)
],
ingestion_parameters=ingestion_params,
),
)
index_client.create_or_update_knowledge_source(knowledge_source=knowledge_source)
print(f"Knowledge source '{knowledge_source.name}' created or updated successfully.")
Reference:SearchIndexClient
### Create an indexed Azure SQL knowledge source
PUT {{search-endpoint}}/knowledgesources/indexedsqlks?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
Content-Type: application/json
{
"name": "indexedsqlks",
"kind": "indexedSql",
"description": "Indexed Azure SQL knowledge source.",
"indexedSqlParameters": {
"connectionString": "Server=tcp:{server}.database.windows.net,1433;Database={db};...;",
"tableOrView": "dbo.tbl_hotels",
"contentColumns": [
{ "name": "hotelName", "sourceField": "HotelName", "searchFieldType": "Edm.String" },
{ "name": "description", "sourceField": "Description", "searchFieldType": "Edm.String" }
],
"embeddingColumns": [
{ "name": "descriptionVector", "sourceField": "Description" }
],
"ingestionParameters": {
"networkAccessMode": "public",
"contentExtractionMode": "minimal",
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "{{aoai-embedding-deployment}}",
"modelName": "{{aoai-embedding-model}}"
}
}
}
}
}
参考:知识源 - 创建或更新
使用 indexedSqlParameters 来标识要引入数据的 SQL 表或视图,并定义列映射,这些列映射会成为生成索引中的字段。 对于视图,指定用于更改检测的高水位线列。
列映射
使用 contentColumns 将 SQL 文本列映射到生成的 Azure AI 搜索 索引中的可搜索字段。 每个内容列映射都会指定目标索引字段、源 SQL 列和 Azure AI 搜索 字段类型。 对于 contentColumns,请使用 Edm.String。
嵌入映射
用于 embeddingColumns 将 SQL 文本列映射到生成的向量字段。 使用嵌入列时,请在 ingestionParameters 中指定嵌入模型。
对于已编制索引的 Azure SQL 知识源,"minimal"必须为contentExtractionMode,因为 SQL 引入过程是基于行的,不会从二进制文档中提取内容。 不支持图像提取和图像语言化,因此chatCompletionModelassetStoreaiServices,与图像相关的设置不起作用。
默认和验证规则
创建索引Azure SQL知识源时,将应用以下默认值。
如果省略
contentColumns,服务会自动将可安全表示为文本的 SQL 列映射到生成索引中的Edm.String字段,并使用 1:1 映射,其中name等于sourceField。如果省略
embeddingColumns,该服务不会创建矢量字段,也不会配置嵌入技能。embeddingColumns独立于contentColumns。 若要使向量与可检索的文本相对应,请在两个数组中包含相同的 SQL 列。源表或视图的主键会被自动发现。 不支持显式重写,并且源必须具有单值主键。
将数据摄取限制在私有网络内
从 2026-08-01-preview API 版本开始,networkAccessMode 用于控制为已编制索引的 Azure SQL 知识源生成的索引器所运行的网络环境。 此设置仅影响引入,不会更改知识库检索请求或响应。
networkAccessMode 默认为 public保留现有公共网络行为。 如果 networkAccessMode 为 private,生成的索引器在 专用执行环境中运行。 它使用批准的共享专用链接来访问Azure SQL 数据库或SQL 托管实例源连接和支持的Azure依赖项,例如Azure OpenAI 模型和 Microsoft Foundry 资源。
配置和验证专用网络访问:
完成 专用网络先决条件。
在知识源创建请求中,将
networkAccessMode设置为private。 只能在创建过程中设置此属性。 若要稍后对其进行更改,请删除并重新创建知识源。如果服务层或运行时不支持专用执行,或者所需的共享专用链接不存在,则创建可能会失败。
确认生成的索引器
executionEnvironment为private.确认每个必需的共享专用链接都已获得批准,并针对正确的依赖项。 仅凭成功创建并不能确认链接已获批准或定向设置已生效。
轮询知识源状态,直到
lastSynchronizationState.endTime具有值。 确认itemsUpdatesFailed为0,然后验证特定于连接器的源内容。 如果无法访问依赖项,同步将失败。
检查摄取状态
运行以下代码来监视引入进度和运行状况,包括知识源类型以及生成索引器管道并填充搜索索引的知识源的详细索引错误。
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);
Reference: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))
Reference: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
}
}
注释
从 2026-04-01 API 版本开始,文档级错误详细信息的 kind 属性和 currentSynchronizationState.errors[] 数组即可使用。 对于早期 API 版本,不会返回这些字段。 该 lastSynchronizationState.status 字段也是 2026-04-01 中的新增字段。
查看生成的对象
创建此知识源时,Azure AI 搜索自动生成数据源、技能集、索引器和索引。 创建响应将列出下 createdResources的每个对象。
这些对象根据固定模板生成,其名称基于知识源的名称。 无法更改对象名称。 避免直接编辑这些对象,因为更改可能会引入中断索引器管道的错误或不兼容。
可以使用Azure门户验证对象创建。 工作流为:
检查索引器是否有成功或失败的消息。 这里会显示连接错误或配额错误。
检查数据源以验证与数据存储的连接。 该连接使用连接字符串或托管标识,具体取决于你如何配置知识源。
检查技能集以查看内容是如何分块和选择性的矢量化的。
检查索引以了解您的内容是如何被编制索引和公开以供检索的,包括哪些字段可供搜索和筛选,以及哪些字段存储用于相似性搜索的向量。 使用搜索资源管理器针对生成的索引运行查询。
分配给知识库
如果对知识源感到满意, 请将其添加到知识库。
查询知识库
配置知识库后, 调用检索操作或 MCP 终结点 以查询知识源。
删除知识源
在删除知识源之前,必须删除引用它的任何知识库或更新知识库定义来去除该引用。 对于生成索引和索引器管道的知识源,所有 生成的对象 都会被删除。 但是,如果使用现有索引创建知识源,则不会删除索引。
如果尝试删除正在使用的知识源,该操作将失败并返回受影响的知识库列表。
要删除知识源,请执行以下步骤:
获取搜索服务上所有知识库的列表。
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}"); }Reference: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);Reference: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.");Reference:SearchIndexClient
删除知识源。
await indexClient.DeleteKnowledgeSourceAsync(knowledgeSourceName); System.Console.WriteLine($"Knowledge source '{knowledgeSourceName}' deleted successfully.");Reference: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}")Reference: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)Reference: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.")Reference: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.")Reference: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}}参考:知识源 - 删除