【问题标题】:How to check if index exists in Cognitive Search?如何检查认知搜索中是否存在索引?
【发布时间】:2021-01-15 10:20:59
【问题描述】:

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

以前在库的 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-core azure-cognitive-search


    【解决方案1】:

    你应该可以使用 SearchIndexClient.GetIndexesAsync 来做这件事。

    【讨论】:

    • 我能够让 GetIndexesAsync 工作 - 是的。但为什么 GetIndexNames 不起作用?
    • 我能够复制。正在调查。
    • 看起来像一个错误,正在跟进。同时,请使用idxclient.GetIndexes().Any(index => index.Name == indexName)检查索引是否存在。我已经验证了它可以工作。
    • 经过验证,这是一个已知问题,正在修复中。很抱歉给您带来不便,请在此期间使用解决方法。
    • 我提交了github.com/Azure/azure-sdk-for-net/issues/15590 以跟踪问题。
    猜你喜欢
    • 2021-07-22
    • 2011-01-09
    • 2016-05-03
    • 2013-03-21
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-11-30
    • 2015-09-16
    相关资源
    最近更新 更多