private static List <Func <object> > IndexCommands(ElasticClient elastic) { return(new List <Func <object> > { () => elastic.CreateIndex("test_index_1"), () => elastic.IndexExists("test_index_1"), () => elastic.UpdateIndexSettings(new UpdateIndexSettingsRequest("test_index_1") { IndexSettings = new IndexSettings() { Sorting = new SortingSettings { Fields = new Field("Title"), }, }, }), () => elastic.Alias(new BulkAliasRequest { Actions = new List <IAliasAction> { new AliasAddAction { Add = new AliasAddOperation { Index = "test_index_1", Alias = "test_index_2", }, }, }, }), () => elastic.GetAliasesPointingToIndex("test_index_1"), () => elastic.PutAlias("test_index_1", "test_index_3"), () => elastic.AliasExists(new AliasExistsRequest("test_index_1")), () => elastic.DeleteAlias(new DeleteAliasRequest("test_index_1", "test_index_3")), () => elastic.DeleteAlias(new DeleteAliasRequest("test_index_1", "test_index_2")), () => elastic.CreateIndex("test_index_4"), #if (ELASTICSEARCH_6_1 && !DEFAULT_SAMPLES) () => elastic.SplitIndex("test_index_1", "test_index_4"), #endif () => elastic.DeleteIndex("test_index_4"), () => elastic.CloseIndex("test_index_1"), () => elastic.OpenIndex("test_index_1"), () => elastic.PutIndexTemplate(new PutIndexTemplateRequest("test_template_1")), () => elastic.IndexTemplateExists("test_template_1"), () => elastic.DeleteIndexTemplate("test_template_1"), () => elastic.IndicesShardStores(), () => elastic.IndicesStats("test_index_1"), () => elastic.DeleteIndex("test_index_1"), () => elastic.GetAlias(new GetAliasRequest()), }); }
protected void CreateInitialIndex(ElasticClient client) { pluginInstance.LogInfo("Setting up initial index and alias"); IExistsResponse aliasExists = client.AliasExists("active-homeseer-index"); if (aliasExists.Exists) { pluginInstance.LogInfo("Alias 'active-homeseer-index' already exists!"); return; } pluginInstance.LogInfo("Creating alias and initial index"); try { client.CreateIndex("homeseer-events-00001", index => index.Aliases(alias => alias.Alias("active-homeseer-index"))); } catch (Exception e) { pluginInstance.LogError(string.Format("Error creating index or alias: {0}", e.Message)); throw; } }
/// <summary> /// Checks if alias already exists /// </summary> /// <param name="alias"></param> /// <returns></returns> public bool IsAliasExist(string alias) { return(defaultClient.AliasExists(aed => aed.Name(alias)).Exists); }
private static List <Func <object> > IndexCommands(ElasticClient elastic) { return(new List <Func <object> > { () => elastic.CreateIndex("test_index_1"), () => elastic.IndexExists("test_index_1"), () => elastic.UpdateIndexSettings(new UpdateIndexSettingsRequest("test_index_1") { IndexSettings = new IndexSettings() { Sorting = new SortingSettings { Fields = new Field("Title"), }, }, }), () => elastic.Alias(new BulkAliasRequest { Actions = new List <IAliasAction> { new AliasAddAction { Add = new AliasAddOperation { Index = "test_index_1", Alias = "test_index_2", }, }, }, }), () => elastic.GetAliasesPointingToIndex("test_index_1"), () => elastic.PutAlias("test_index_1", "test_index_3"), () => elastic.AliasExists(new AliasExistsRequest("test_index_1")), () => elastic.DeleteAlias(new DeleteAliasRequest("test_index_1", "test_index_3")), () => elastic.DeleteAlias(new DeleteAliasRequest("test_index_1", "test_index_2")), () => elastic.CreateIndex("test_index_4"), #if (ELASTICSEARCH_6_1 && !DEFAULT_SAMPLES) () => elastic.SplitIndex("test_index_1", "test_index_4"), #endif () => elastic.DeleteIndex("test_index_4"), () => elastic.CloseIndex("test_index_1"), () => elastic.OpenIndex("test_index_1"), () => elastic.PutIndexTemplate(new PutIndexTemplateRequest("test_template_1")), () => elastic.IndexTemplateExists("test_template_1"), () => elastic.DeleteIndexTemplate("test_template_1"), () => elastic.IndicesShardStores(), () => elastic.IndicesStats("test_index_1"), () => elastic.DeleteIndex("test_index_1"), () => elastic.GetAlias(new GetAliasRequest()), () => elastic.ReindexOnServer(new ReindexOnServerRequest { Source = new ReindexSource { Remote = new RemoteSource { Host = new Uri("http://" + Host()), Username = "******", Password = "******" }, Index = "some_index", Size = 10 }, Destination = new ReindexDestination { Index = "some_index_clone", } }) }); }