首页 > 解决方案 > 如何检查认知搜索中是否存在索引?

问题描述

我想知道我的搜索实例中是否已经存在索引。

以前在图书馆的 v10 中,我可以这样做:

if (serviceClient.Indexes.Exists(indexName)) {...}

在 v11 中,SearchServiceClient已被替换为SearchIndexClient没有.Indexes集合的 。

我尝试了下面的代码,但它爆炸了Fields cannot be null. To clear values, call Clear. (Parameter 'value')

string match = indexClient.GetIndexNames().SingleOrDefault(i => i == indexName);

那么查看索引是否存在的新方法是什么?

标签: .net.net-coreazure-cognitive-search

解决方案


你应该可以使用SearchIndexClient.GetIndexesAsync它。


推荐阅读