WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Aliasingedit
Adding/removing and updating aliases are also easy to do in NEST. For more information look at the Alias documentation
Addedit
Fluent Syntaxedit
client.Alias(a => a .Add(add => add .Index("myindex") .Alias("myalias") ) );
Object Initializer Syntaxedit
var request = new AliasRequest { Actions = new IAliasAction[] { new AliasAddAction { Add = new AliasAddOperation { Index = "myindex", Alias = "myalias" } } } }; client.Alias(request);
Removeedit
Fluent Syntaxedit
client.Alias(a => a .Remove(remove => remove .Index("myindex") .Alias("myalias") ) );
Object Initializer Syntaxedit
var request = new AliasRequest { Actions = new IAliasAction[] { new AliasRemoveAction { Remove = new AliasRemoveOperation { Index = "myindex", Alias = "myalias" } } } }; client.Alias(request);
Renameedit
To rename an alias, just do an Add and a Remove in the same operation. Elasticsearch will then atomically rename your alias:
Fluent Syntaxedit
client.Alias(a => a .Add(add => add .Index("myindex") .Alias("newalias") ) .Remove(remove => remove .Index("myindex") .Alias("oldalias") ) );
Object Initializer Syntaxedit
var request = new AliasRequest { Actions = new IAliasAction[] { new AliasAddAction { Add = new AliasAddOperation { Index = "myindex", Alias = "myalias" } }, new AliasRemoveAction { Remove = new AliasRemoveOperation { Index = "myindex", Alias = "myalias" } } } }; client.Alias(request);