共用方式為


SearchIndexClient.CreateOrUpdateIndexAsync Method

Definition

Creates a new search index or updates an existing index.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Indexes.Models.SearchIndex>> CreateOrUpdateIndexAsync (Azure.Search.Documents.Indexes.Models.SearchIndex index, bool allowIndexDowntime = false, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrUpdateIndexAsync : Azure.Search.Documents.Indexes.Models.SearchIndex * bool * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Indexes.Models.SearchIndex>>
override this.CreateOrUpdateIndexAsync : Azure.Search.Documents.Indexes.Models.SearchIndex * bool * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Indexes.Models.SearchIndex>>
Public Overridable Function CreateOrUpdateIndexAsync (index As SearchIndex, Optional allowIndexDowntime As Boolean = false, Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SearchIndex))

Parameters

index
SearchIndex

Required. The SearchIndex to create or update.

allowIndexDowntime
Boolean

Optional value indicating whether to allow analyzers, tokenizers, token filters, or character filters to be added to the index by temporarily taking the index offline for a few seconds. The default is false. This temporarily causes indexing and queries to fail. Performance and write availability of the index can be impaired for several minutes after the index is updated, or longer for very large indexes.

onlyIfUnchanged
Boolean

True to throw a RequestFailedException if the ETag does not match the current service version; otherwise, the current service version will be overwritten.

cancellationToken
CancellationToken

Optional CancellationToken to propagate notifications that the operation should be canceled.

Returns

The Response<T> from the server containing the SearchIndex that was created or updated. This may differ slightly from what was passed in since the service may return back fields set to their default values depending on the field type and other properties.

Exceptions

Thrown when index is null.

Thrown when a failure is returned by the Search service.

Applies to