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.
Aliasing
editAliasing
editAdding/removing and updating aliases are also easy to do in NEST. For more information look at the Alias documentation
Add
editFluent Syntax
editclient.Alias(a => a .Add(add => add .Index("myindex") .Alias("myalias") ) );
Object Initializer Syntax
editvar request = new AliasRequest { Actions = new IAliasAction[] { new AliasAddAction { Add = new AliasAddOperation { Index = "myindex", Alias = "myalias" } } } }; client.Alias(request);
Remove
editFluent Syntax
editclient.Alias(a => a .Remove(remove => remove .Index("myindex") .Alias("myalias") ) );
Object Initializer Syntax
editvar request = new AliasRequest { Actions = new IAliasAction[] { new AliasRemoveAction { Remove = new AliasRemoveOperation { Index = "myindex", Alias = "myalias" } } } }; client.Alias(request);
Rename
editTo rename an alias, just do an Add and a Remove in the same operation. Elasticsearch will then atomically rename your alias:
Fluent Syntax
editclient.Alias(a => a .Add(add => add .Index("myindex") .Alias("newalias") ) .Remove(remove => remove .Index("myindex") .Alias("oldalias") ) );
Object Initializer Syntax
editvar 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);