C# 如何使用Azure Search SDK(库)删除文档(表)或一组文档

C# 如何使用Azure Search SDK(库)删除文档(表)或一组文档,c#,azure-cognitive-search,azure-search-.net-sdk,C#,Azure Cognitive Search,Azure Search .net Sdk,我想使用Microsoft.Azure.Search库使用文档Id删除项目文档。我该怎么做 以下是我迄今为止所尝试的: public Task DeleteItems(IEnumerable<string> itemsIds) { return Task.Run(() => { IndexBatch<string> batch = IndexBatch.Delete<

我想使用Microsoft.Azure.Search库使用文档Id删除项目文档。我该怎么做

以下是我迄今为止所尝试的:

public Task DeleteItems(IEnumerable<string> itemsIds)
        {
            return Task.Run(() =>
            {
                IndexBatch<string> batch = IndexBatch.Delete<string>(itemsIds);
                try
                {
                     //Gets the search service and add the delete batch to be perfomed on the Index
                    this.GetSearchServiceIndex().Documents.Index(batch);
                }
                catch (IndexBatchException ex)
                {
                    //Do something in here
                }
            });
        }
我发现我适应了我的情况。最终结果如下:

public Task DeleteItems(IEnumerable<string> itemsIds)
    {
        return Task.Run(() =>
        {
            IndexBatch batch = IndexBatch.Delete("id", itemsIds);
            try
            {
                //Gets the search service and add the delete batch to be perfomed on the Index
                this.GetSearchServiceIndex().Documents.Index(batch);
            }
            catch (IndexBatchException ex)
            {
                //Do Someting here
            }
        });
    }