AngryHacker
AngryHacker

Reputation: 61596

How to check if index exists in Cognitive Search?

I'd like to find out whether an Index already exists in my search instance.

Previously in v10 of the library, I could do:

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

With v11, SearchServiceClient has been replaced by SearchIndexClient, which doesn't have .Indexes collection.

I tried code below, but it blows up with Fields cannot be null. To clear values, call Clear. (Parameter 'value'):

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

So what is the new way to see if an index exists?

Upvotes: 0

Views: 2557

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

You should be able to use SearchIndexClient.GetIndexesAsync for that.

Upvotes: 2

Related Questions