| | 91 | |
| | 92 | |
| | 93 | Directly manage to ES |
| | 94 | {{{ |
| | 95 | |
| | 96 | curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/test1/_doc" -d "{ \"id\" : 1}" |
| | 97 | curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/test2/_doc" -d "{ \"id\" : 2}" |
| | 98 | |
| | 99 | curl -X GET http://127.0.0.1:9200/test1/_doc/_search?pretty |
| | 100 | |
| | 101 | # alias add with |
| | 102 | # 1st method |
| | 103 | curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' |
| | 104 | { |
| | 105 | "actions" : [ |
| | 106 | { "add" : { "indices" : ["test1", "test2"], "alias" : "test" } } |
| | 107 | ] |
| | 108 | }' |
| | 109 | |
| | 110 | # 2nd method |
| | 111 | curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' |
| | 112 | { |
| | 113 | "actions" : [ |
| | 114 | { "add" : { "index" : "test1", "alias" : "alias1" } }, |
| | 115 | { "add" : { "index" : "test2", "alias" : "alias1" } } |
| | 116 | ] |
| | 117 | }' |
| | 118 | |
| | 119 | # remove test2 from alias test |
| | 120 | curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' |
| | 121 | { |
| | 122 | "actions" : [ |
| | 123 | { "remove" : { "index" : "test2", "alias" : "test" } } |
| | 124 | ] |
| | 125 | }' |
| | 126 | |
| | 127 | # remove test1 from alias test and add test2 to alias test |
| | 128 | curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' |
| | 129 | { |
| | 130 | "actions" : [ |
| | 131 | { "remove" : { "index" : "test1", "alias" : "test" } }, |
| | 132 | { "add" : { "index" : "test2", "alias" : "test" } } |
| | 133 | ] |
| | 134 | }' |
| | 135 | |
| | 136 | |
| | 137 | curl -X GET localhost:9200/_cat/indices |
| | 138 | |
| | 139 | #Once you have deleted your index, the alias will also get deleted. |
| | 140 | #In your case, you can directly delete test1 and test2. |
| | 141 | }}} |