【发布时间】:2023-01-05 07:10:08
【问题描述】:
我在我的 .Net Core 3.1 应用程序中使用 Azure.Search.Documents 包来实现 azure 认知搜索。我有要求必须从文档中删除现有数据。我通过参考文档尝试了几种方法,但都没有用。
我尝试了以下方法
方法一
var searchIndexClient = new SearchIndexClient(new Uri(<URI>), new AzureKeyCredential("XYZ"));
var searchClient = searchIndexClient.GetSearchClient(indexName);
var options = new IndexDocumentsOptions { ThrowOnAnyError = true };
var res = await searchClient.DeleteDocumentsAsync("Id", new List<string> { "1", "2", "3"}, options);
方法二:
var searchIndexClient = new SearchIndexClient(new Uri(<URI>), new AzureKeyCredential("XYZ"));
var searchClient = searchIndexClient.GetSearchClient(indexName);
var batch = IndexDocumentsBatch.Delete("Id", documents);
var options = new IndexDocumentsOptions { ThrowOnAnyError = true };
var res = await searchClient.IndexDocumentsAsync(batch, options);
当我尝试这些方法时,出现以下错误:
{
"error": {
"code": "MissingRequiredParameter",
"message": "The request is invalid. Details: actions : No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request.",
"details": [{
"code": "MissingIndexDocumentsActions",
"message": "No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request. Parameters: actions"
}
]
}
}
感谢任何帮助,注意:我只想使用 SDK 而不是 Rest API
【问题讨论】:
标签: c# azure .net-core azure-cognitive-search