Skip to content

Commit b7ab138

Browse files
committed
[Docs] Update Aliasing section with OIS examples
1 parent 5d80d8d commit b7ab138

File tree

1 file changed

+77
-22
lines changed

1 file changed

+77
-22
lines changed

docs/contents/nest/indices/aliases.markdown

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,90 @@ menuitem: aliases
1010

1111
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)
1212

13-
## Adding
13+
## Add
1414

15-
_client.Alias(a => a
16-
.Add(add => add
17-
.Index("myindex")
18-
.Alias("myalias")));
15+
### Fluent Syntax
1916

20-
## Removing
17+
client.Alias(a => a
18+
.Add(add => add
19+
.Index("myindex")
20+
.Alias("myalias")
21+
)
22+
);
2123

22-
_client.Alias(a => a
23-
.Remove(remove => remove
24-
.Index("myindex")
25-
.Alias("myalias")));
24+
### Object Initializer Syntax
2625

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+
};
2736

28-
## Renaming
37+
client.Alias(request);
2938

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
3140

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
3942

40-
## Asynchronous
43+
client.Alias(a => a
44+
.Remove(remove => remove
45+
.Index("myindex")
46+
.Alias("myalias")
47+
)
48+
);
4149

42-
Doing alias operations Async is simple:
50+
### Object Initializer Syntax
4351

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" }
95+
}
96+
}
97+
};
98+
99+
client.Alias(request);

0 commit comments

Comments
 (0)