Skip to content

Commit 73826f9

Browse files
bastienXWB
authored andcommitted
Be a little bit verbose (#1524)
change orders actions to avoid downtime and add some usefull informations
1 parent 3ce45fe commit 73826f9

File tree

1 file changed

+60
-8
lines changed

1 file changed

+60
-8
lines changed

doc/cookbook/aliased-indexes.md

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,84 @@ fos_elastica:
1818
```
1919
2020
The process for setting up aliases on an existing application is slightly more complicated
21-
because the bundle is not able to set an alias as the same name as an index. You have some
21+
because the bundle is not able to set an alias as the same name as an index. You have 2
2222
options on how to handle this:
2323
24-
1) Delete the index from Elasticsearch. This option will make searching unavailable in your
24+
1) Option with downtime : Delete the index from Elasticsearch. This option will make searching unavailable in your
2525
application until a population has completed itself, and an alias is created.
2626
2727
```bash
2828
$ curl -XDELETE 'http://localhost:9200/app/'
2929
```
3030

31-
2) Change the index_name parameter for your index to something new, and manually alias the
31+
2) Option without downtime : Change the index_name parameter for your index to something new, and manually alias the
3232
current index to the new index_name, which will then be replaced when you run a repopulate.
3333

34+
```bash
35+
# before actions
36+
curl -XGET 'http://localhost:9200/_alias/?pretty'
37+
{
38+
"app" : {
39+
"aliases" : { }
40+
}
41+
}
42+
43+
# create alias to switch after with no downtime
44+
$ curl -XPOST 'http://localhost:9200/_aliases' -H 'Content-Type: application/json' -d '
45+
{
46+
"actions" : [
47+
{ "add" : { "index" : "app", "alias" : "app_prod" } }
48+
]
49+
}'
50+
51+
#check alias is ok
52+
curl -XGET 'http://localhost:9200/_alias/?pretty'
53+
{
54+
"app" : {
55+
"aliases" : { "app_prod" : { } }
56+
}
57+
}
58+
59+
```
60+
3461
```yaml
62+
#index name is alias name
3563
fos_elastica:
3664
indexes:
3765
app:
3866
use_alias: true
3967
index_name: app_prod
4068
```
4169
70+
clear caches etc, now fos use alias instead of index
4271
```bash
43-
$ curl -XPOST 'http://localhost:9200/_aliases' -H 'Content-Type: application/json' -d '
72+
bin/console -eprod 'fos:elastica:populate'
73+
```
74+
in other cli in // check indexes during populate process
75+
```bash
76+
curl -XGET 'http://localhost:9200/_alias/?pretty'
4477
{
45-
"actions" : [
46-
{ "add" : { "index" : "app", "alias" : "app_prod" } }
47-
]
48-
}'
78+
"app" : {
79+
"aliases" : {
80+
"app_prod" : { }
81+
}
82+
},
83+
"app_prod_2019-05-28-153852" : {
84+
"aliases" : { }
85+
}
86+
}
87+
88+
```
89+
when 'fos:elastica:populate' command finish
90+
91+
```bash
92+
curl -XGET 'http://localhost:9200/_alias/?pretty'
93+
{
94+
"app_prod_2019-05-28-153852" : {
95+
"aliases" : {
96+
"app_prod" : { }
97+
}
98+
}
99+
}
100+
49101
```

0 commit comments

Comments
 (0)