You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contents/nest/indices/aliases.markdown
+77-22Lines changed: 77 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,35 +10,90 @@ menuitem: aliases
10
10
11
11
Adding/removing and updating aliases are also easy to do in NEST. For more information look at the [Alias Doc](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html)
12
12
13
-
## Adding
13
+
## Add
14
14
15
-
_client.Alias(a => a
16
-
.Add(add => add
17
-
.Index("myindex")
18
-
.Alias("myalias")));
15
+
### Fluent Syntax
19
16
20
-
## Removing
17
+
client.Alias(a => a
18
+
.Add(add => add
19
+
.Index("myindex")
20
+
.Alias("myalias")
21
+
)
22
+
);
21
23
22
-
_client.Alias(a => a
23
-
.Remove(remove => remove
24
-
.Index("myindex")
25
-
.Alias("myalias")));
24
+
### Object Initializer Syntax
26
25
26
+
var request = new AliasRequest
27
+
{
28
+
Actions = new IAliasAction[]
29
+
{
30
+
new AliasAddAction
31
+
{
32
+
Add = new AliasAddOperation { Index = "myindex", Alias = "myalias" }
33
+
}
34
+
}
35
+
};
27
36
28
-
## Renaming
37
+
client.Alias(request);
29
38
30
-
To rename a alias, just do an Add and a Remove in the same operation. Elasticsearch will then atomically rename your alias
39
+
## Remove
31
40
32
-
_client.Alias(a => a
33
-
.Add(add => add
34
-
.Index("myindex")
35
-
.Alias("newalias"))
36
-
.Remove(remove => remove
37
-
.Index("myindex")
38
-
.Alias("oldalias")));
41
+
### Fluent Syntax
39
42
40
-
## Asynchronous
43
+
client.Alias(a => a
44
+
.Remove(remove => remove
45
+
.Index("myindex")
46
+
.Alias("myalias")
47
+
)
48
+
);
41
49
42
-
Doing alias operations Async is simple:
50
+
### Object Initializer Syntax
43
51
44
-
_client.AliasAsync(...);
52
+
var request = new AliasRequest
53
+
{
54
+
Actions = new IAliasAction[]
55
+
{
56
+
new AliasRemoveAction
57
+
{
58
+
Remove = new AliasRemoveOperation { Index = "myindex", Alias = "myalias" }
59
+
}
60
+
}
61
+
};
62
+
63
+
client.Alias(request);
64
+
65
+
## Rename
66
+
67
+
To rename an alias, just do an Add and a Remove in the same operation. Elasticsearch will then atomically rename your alias:
68
+
69
+
### Fluent Syntax
70
+
71
+
client.Alias(a => a
72
+
.Add(add => add
73
+
.Index("myindex")
74
+
.Alias("newalias")
75
+
)
76
+
.Remove(remove => remove
77
+
.Index("myindex")
78
+
.Alias("oldalias")
79
+
)
80
+
);
81
+
82
+
### Object Initializer Syntax
83
+
84
+
var request = new AliasRequest
85
+
{
86
+
Actions = new IAliasAction[]
87
+
{
88
+
new AliasAddAction
89
+
{
90
+
Add = new AliasAddOperation { Index = "myindex", Alias = "myalias" }
91
+
},
92
+
new AliasRemoveAction
93
+
{
94
+
Remove = new AliasRemoveOperation { Index = "myindex", Alias = "myalias" }
0 commit comments