|
| 1 | +[[indices-get-alias]] |
| 2 | +=== Get index alias API |
| 3 | +++++ |
| 4 | +<titleabbrev>Get index alias</titleabbrev> |
| 5 | +++++ |
| 6 | + |
| 7 | +Returns information about one or more index aliases. |
| 8 | + |
| 9 | +include::alias-exists.asciidoc[tag=index-alias-def] |
| 10 | + |
| 11 | +[source,js] |
| 12 | +---- |
| 13 | +GET /twitter/_alias/alias1 |
| 14 | +---- |
| 15 | +// CONSOLE |
| 16 | +// TEST[setup:twitter] |
| 17 | +// TEST[s/^/PUT twitter\/_alias\/alias1\n/] |
| 18 | + |
| 19 | + |
| 20 | +[[get-alias-api-request]] |
| 21 | +==== {api-request-title} |
| 22 | + |
| 23 | +`GET /_alias` |
| 24 | + |
| 25 | +`GET /_alias/<alias>` |
| 26 | + |
| 27 | +`GET /<index>/_alias/<alias>` |
| 28 | + |
| 29 | + |
| 30 | +[[get-alias-api-path-params]] |
| 31 | +==== {api-path-parms-title} |
| 32 | + |
| 33 | +`<alias>`:: |
| 34 | +(Optional, string) |
| 35 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index-alias] |
| 36 | ++ |
| 37 | +To retrieve information for all index aliases, |
| 38 | +use a value of `_all` or `*`. |
| 39 | + |
| 40 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index] |
| 41 | + |
| 42 | + |
| 43 | +[[get-alias-api-query-params]] |
| 44 | +==== {api-query-parms-title} |
| 45 | + |
| 46 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices] |
| 47 | + |
| 48 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards] |
| 49 | ++ |
| 50 | +Defaults to `all`. |
| 51 | + |
| 52 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable] |
| 53 | + |
| 54 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=local] |
| 55 | + |
| 56 | + |
| 57 | +[[get-alias-api-example]] |
| 58 | +==== {api-examples-title} |
| 59 | + |
| 60 | +[[get-alias-api-all-ex]] |
| 61 | +===== Get all aliases for an index |
| 62 | + |
| 63 | +You can add index aliases during index creation |
| 64 | +using a <<indices-create-index,create index API>> request. |
| 65 | + |
| 66 | +The following create index API request creates the `logs_20302801` index |
| 67 | +with two aliases: |
| 68 | + |
| 69 | +* `current_day` |
| 70 | +* `2030`, which only returns documents |
| 71 | +in the `logs_20302801` index |
| 72 | +with a `year` field value of `2030` |
| 73 | + |
| 74 | +[source,js] |
| 75 | +-------------------------------------------------- |
| 76 | +PUT /logs_20302801 |
| 77 | +{ |
| 78 | + "aliases" : { |
| 79 | + "current_day" : {}, |
| 80 | + "2030" : { |
| 81 | + "filter" : { |
| 82 | + "term" : {"year" : 2030 } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | +-------------------------------------------------- |
| 88 | +// CONSOLE |
| 89 | + |
| 90 | +The following get index alias API request returns all aliases |
| 91 | +for the index `logs_20302801`: |
| 92 | + |
| 93 | +[source,js] |
| 94 | +-------------------------------------------------- |
| 95 | +GET /logs_20302801/_alias/* |
| 96 | +-------------------------------------------------- |
| 97 | +// CONSOLE |
| 98 | +// TEST[continued] |
| 99 | + |
| 100 | +The API returns the following response: |
| 101 | + |
| 102 | +[source,js] |
| 103 | +-------------------------------------------------- |
| 104 | +{ |
| 105 | + "logs_20302801" : { |
| 106 | + "aliases" : { |
| 107 | + "current_day" : { |
| 108 | + }, |
| 109 | + "2030" : { |
| 110 | + "filter" : { |
| 111 | + "term" : { |
| 112 | + "year" : 2030 |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | +} |
| 119 | +-------------------------------------------------- |
| 120 | +// TESTRESPONSE |
| 121 | + |
| 122 | + |
| 123 | +[[get-alias-api-named-ex]] |
| 124 | +===== Get a specific alias |
| 125 | + |
| 126 | +The following index alias API request returns the `2030` alias: |
| 127 | + |
| 128 | +[source,js] |
| 129 | +-------------------------------------------------- |
| 130 | +GET /_alias/2030 |
| 131 | +-------------------------------------------------- |
| 132 | +// CONSOLE |
| 133 | +// TEST[continued] |
| 134 | + |
| 135 | +The API returns the following response: |
| 136 | + |
| 137 | +[source,js] |
| 138 | +-------------------------------------------------- |
| 139 | +{ |
| 140 | + "logs_20302801" : { |
| 141 | + "aliases" : { |
| 142 | + "2030" : { |
| 143 | + "filter" : { |
| 144 | + "term" : { |
| 145 | + "year" : 2030 |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | +-------------------------------------------------- |
| 153 | +// TESTRESPONSE |
| 154 | + |
| 155 | +[[get-alias-api-wildcard-ex]] |
| 156 | +===== Get aliases based on a wildcard |
| 157 | + |
| 158 | +The following index alias API request returns any alias that begin with `20`: |
| 159 | + |
| 160 | +[source,js] |
| 161 | +-------------------------------------------------- |
| 162 | +GET /_alias/20* |
| 163 | +-------------------------------------------------- |
| 164 | +// CONSOLE |
| 165 | +// TEST[continued] |
| 166 | + |
| 167 | +The API returns the following response: |
| 168 | + |
| 169 | +[source,js] |
| 170 | +-------------------------------------------------- |
| 171 | +{ |
| 172 | + "logs_20302801" : { |
| 173 | + "aliases" : { |
| 174 | + "2030" : { |
| 175 | + "filter" : { |
| 176 | + "term" : { |
| 177 | + "year" : 2030 |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | +} |
| 184 | +-------------------------------------------------- |
| 185 | +// TESTRESPONSE |
0 commit comments