本文整理汇总了C#中IElasticClient.DeleteIndex方法的典型用法代码示例。如果您正苦于以下问题:C# IElasticClient.DeleteIndex方法的具体用法?C# IElasticClient.DeleteIndex怎么用?C# IElasticClient.DeleteIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElasticClient
的用法示例。
在下文中一共展示了IElasticClient.DeleteIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(string uri = "http://localhost:9200/", bool deleteIndex = false)
{
_logger.Info("Initialing elastic search with uri: " + uri);
var connectionString = new ConnectionSettings(
new Uri(uri))
.DefaultIndex(OSM_NAMES_INDEX)
.PrettyJson();
_elasticClient = new ElasticClient(connectionString);
if (deleteIndex && _elasticClient.IndexExists(OSM_NAMES_INDEX).Exists)
{
_elasticClient.DeleteIndex(OSM_NAMES_INDEX);
}
if (deleteIndex && _elasticClient.IndexExists(OSM_HIGHWAYS_INDEX).Exists)
{
_elasticClient.DeleteIndex(OSM_HIGHWAYS_INDEX);
}
_elasticClient.CreateIndex(OSM_HIGHWAYS_INDEX,
c => c.Mappings(
ms => ms.Map<object>(m =>
m.Properties(ps => ps.GeoShape(g => g.Name("geometry")
.Tree(GeoTree.Geohash)
.TreeLevels(10)
.DistanceErrorPercentage(0.2))))));
_logger.Info("Finished initialing elastic search with uri: " + uri);
}
示例2: DeleteIndexes
public void DeleteIndexes(IElasticClient client) {
var deleteResponse = client.DeleteIndex(i => i.AllIndices());
Debug.Assert(deleteResponse.IsValid, deleteResponse.ServerError != null ? deleteResponse.ServerError.Error : "An error occurred deleting the indexes.");
foreach (var index in GetIndexes()) {
var templatedIndex = index as ITemplatedElasticSeachIndex;
if (templatedIndex != null) {
if (client.TemplateExists(index.VersionedName).Exists) {
var response = client.DeleteTemplate(index.VersionedName);
Debug.Assert(response.IsValid, response.ServerError != null ? response.ServerError.Error : "An error occurred deleting the index template.");
}
}
}
}
示例3: ConfigureMapping
private static void ConfigureMapping(IElasticClient searchclient, bool deleteExistingIndexes = false) {
if (deleteExistingIndexes)
searchclient.DeleteIndex(i => i.AllIndices());
if (!searchclient.IndexExists(new IndexExistsRequest(new IndexNameMarker { Name = ElasticSearchRepository<Stack>.StacksIndexName })).Exists)
searchclient.CreateIndex(ElasticSearchRepository<Stack>.StacksIndexName, d => d
.AddAlias("stacks")
.AddMapping<Stack>(map => map
.Dynamic(DynamicMappingOption.Ignore)
.IncludeInAll(false)
.Properties(p => p
.String(f => f.Name(s => s.OrganizationId).IndexName("organization").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(s => s.ProjectId).IndexName("project").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(s => s.SignatureHash).IndexName("signature").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.Type).IndexName("type").Index(FieldIndexOption.NotAnalyzed))
.Date(f => f.Name(s => s.FirstOccurrence).IndexName("first"))
.Date(f => f.Name(s => s.LastOccurrence).IndexName("last"))
.String(f => f.Name(s => s.Title).IndexName("title").Index(FieldIndexOption.Analyzed).IncludeInAll().Boost(1.1))
.String(f => f.Name(s => s.Description).IndexName("description").Index(FieldIndexOption.Analyzed).IncludeInAll())
.String(f => f.Name(s => s.Tags).IndexName("tag").Index(FieldIndexOption.NotAnalyzed).IncludeInAll().Boost(1.2))
.String(f => f.Name(s => s.References).IndexName("references").Index(FieldIndexOption.Analyzed).IncludeInAll())
.Date(f => f.Name(s => s.DateFixed).IndexName("fixed"))
.Boolean(f => f.Name(s => s.IsHidden).IndexName("hidden"))
.Boolean(f => f.Name(s => s.IsRegressed).IndexName("regressed"))
.Boolean(f => f.Name(s => s.OccurrencesAreCritical).IndexName("critical"))
.Number(f => f.Name(s => s.TotalOccurrences).IndexName("occurrences"))
)
)
);
searchclient.PutTemplate(ElasticSearchRepository<PersistentEvent>.EventsIndexName, d => d
.Template(ElasticSearchRepository<PersistentEvent>.EventsIndexName + "-*")
.AddMapping<PersistentEvent>(map => map
.Dynamic(DynamicMappingOption.Ignore)
.IncludeInAll(false)
.DisableSizeField(false)
.Properties(p => p
.String(f => f.Name(e => e.OrganizationId).IndexName("organization").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.ProjectId).IndexName("project").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.StackId).IndexName("stack").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.ReferenceId).IndexName("reference").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.SessionId).IndexName("session").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.Type).IndexName("type").Index(FieldIndexOption.NotAnalyzed))
.String(f => f.Name(e => e.Source).IndexName("source").Index(FieldIndexOption.NotAnalyzed).IncludeInAll())
.Date(f => f.Name(e => e.Date).IndexName("date"))
.String(f => f.Name(e => e.Message).IndexName("message").Index(FieldIndexOption.Analyzed).IncludeInAll())
.String(f => f.Name(e => e.Tags).IndexName("tag").Index(FieldIndexOption.NotAnalyzed).IncludeInAll().Boost(1.1))
.Boolean(f => f.Name(e => e.IsFirstOccurrence).IndexName("first"))
.Boolean(f => f.Name(e => e.IsFixed).IndexName("fixed"))
.Boolean(f => f.Name(e => e.IsHidden).IndexName("hidden"))
.Object<DataDictionary>(f => f.Name(e => e.Data).Properties(p2 => p2
.String(f2 => f2.Name(Event.KnownDataKeys.Version).Index(FieldIndexOption.NotAnalyzed))
.Object<RequestInfo>(f2 => f2.Name(Event.KnownDataKeys.RequestInfo).Properties(p3 => p3
.String(f3 => f3.Name(r => r.ClientIpAddress).IndexName("ip").Index(FieldIndexOption.Analyzed).IncludeInAll())))
.Object<Error>(f2 => f2.Name(Event.KnownDataKeys.Error).Properties(p3 => p3
.String(f3 => f3.Name(r => r.Type).Index(FieldIndexOption.Analyzed).IncludeInAll())))
.Object<EnvironmentInfo>(f2 => f2.Name(Event.KnownDataKeys.EnvironmentInfo).Properties(p3 => p3
.String(f3 => f3.Name(r => r.MachineName).Index(FieldIndexOption.Analyzed).IncludeInAll())))
.Object<UserInfo>(f2 => f2.Name(Event.KnownDataKeys.UserInfo).Properties(p3 => p3
.String(f3 => f3.Name(r => r.Identity).Index(FieldIndexOption.Analyzed).IncludeInAll().Boost(1.1))))))
)
)
);
}
示例4: ClearItems
public static void ClearItems(IElasticClient client)
{
client.DeleteIndex(i => i.Index<Person>());
//client.DeleteByQuery<Person>(q => q.AllIndices().MatchAll());
}
示例5: DeleteIndexes
public virtual void DeleteIndexes(IElasticClient client, IEnumerable<IElasticIndex> indexes = null) {
if (indexes == null)
indexes = GetIndexes();
foreach (var idx in indexes) {
IIndicesResponse deleteResponse;
var templatedIndex = idx as ITemplatedElasticIndex;
if (templatedIndex != null) {
deleteResponse = client.DeleteIndex(idx.VersionedName + "-*");
if (client.TemplateExists(idx.VersionedName).Exists) {
var response = client.DeleteTemplate(idx.VersionedName);
Debug.Assert(response.IsValid, response.ServerError != null ? response.ServerError.Error : "An error occurred deleting the index template.");
}
} else {
deleteResponse = client.DeleteIndex(idx.VersionedName);
}
Debug.Assert(deleteResponse.IsValid, deleteResponse.ServerError != null ? deleteResponse.ServerError.Error : "An error occurred deleting the indexes.");
}
}