本文整理汇总了C#中Nest.ElasticClient.IndexExistsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticClient.IndexExistsAsync方法的具体用法?C# ElasticClient.IndexExistsAsync怎么用?C# ElasticClient.IndexExistsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nest.ElasticClient
的用法示例。
在下文中一共展示了ElasticClient.IndexExistsAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureIndexExists
private async Task EnsureIndexExists(string currentIndexName, ElasticClient esClient)
{
IExistsResponse existsResult = await esClient.IndexExistsAsync(currentIndexName);
if (!existsResult.IsValid)
{
this.ReportEsRequestError(existsResult, "Index exists check");
}
if (existsResult.Exists)
{
return;
}
// TODO: allow the consumer to fine-tune index settings
IndexState indexState = new IndexState();
indexState.Settings = new IndexSettings();
indexState.Settings.NumberOfReplicas = 1;
indexState.Settings.NumberOfShards = 5;
indexState.Settings.Add("refresh_interval", "15s");
ICreateIndexResponse createIndexResult = await esClient.CreateIndexAsync(currentIndexName, c => c.InitializeUsing(indexState));
if (!createIndexResult.IsValid)
{
if (createIndexResult.ServerError != null &&
createIndexResult.ServerError.Error != null &&
string.Equals(createIndexResult.ServerError.Error.Type, "IndexAlreadyExistsException", StringComparison.OrdinalIgnoreCase))
{
// This is fine, someone just beat us to create a new index.
return;
}
this.ReportEsRequestError(createIndexResult, "Create index");
}
}
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:35,代码来源:ElasticSearchListener.cs