<p dir="auto"><code class="notranslate">GET /{index}/_aliases/{name}</code> is supposed to filter aliases by index and/or by name.</p>
<p dir="auto">But if you want to filter only by alias <code class="notranslate">name</code>, it gives you back all indices:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="curl -XDELETE localhost:9200/foo,bar?pretty
curl -XPUT localhost:9200/foo?pretty
curl -XPUT localhost:9200/bar?pretty
curl -XPOST localhost:9200/_aliases?pretty -d '{
    &quot;actions&quot; : [
        { &quot;add&quot; : { &quot;index&quot; : &quot;foo&quot;, &quot;alias&quot; : &quot;myalias&quot; } }
    ]
}'

# Correct
curl -XGET localhost:9200/_aliases?pretty
# {
#   &quot;bar&quot; : {
#     &quot;aliases&quot; : { }
#   },
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }

# Correct
curl -XGET localhost:9200/foo/_aliases?pretty
# {
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }

# Incorrect
curl -XGET localhost:9200/_aliases/myalias?pretty
# {
#   &quot;bar&quot; : {
#     &quot;aliases&quot; : { }
#   },
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }


# Correct
curl -XGET localhost:9200/_alias?pretty
# {
#   &quot;bar&quot; : {
#     &quot;aliases&quot; : { }
#   },
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }

# Correct
curl -XGET localhost:9200/foo/_alias?pretty
# {
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }

# Correct
curl -XGET localhost:9200/_alias/myalias?pretty
# {
#   &quot;foo&quot; : {
#     &quot;aliases&quot; : {
#       &quot;myalias&quot; : { }
#     }
#   }
# }"><pre class="notranslate">curl -XDELETE localhost:9200/foo,bar<span class="pl-k">?</span>pretty
curl -XPUT localhost:9200/foo<span class="pl-k">?</span>pretty
curl -XPUT localhost:9200/bar<span class="pl-k">?</span>pretty
curl -XPOST localhost:9200/_aliases<span class="pl-k">?</span>pretty -d <span class="pl-s"><span class="pl-pds">'</span>{</span>
<span class="pl-s">    "actions" : [</span>
<span class="pl-s">        { "add" : { "index" : "foo", "alias" : "myalias" } }</span>
<span class="pl-s">    ]</span>
<span class="pl-s">}<span class="pl-pds">'</span></span>

<span class="pl-c"><span class="pl-c">#</span> Correct</span>
curl -XGET localhost:9200/_aliases<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "bar" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>   },</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>

<span class="pl-c"><span class="pl-c">#</span> Correct</span>
curl -XGET localhost:9200/foo/_aliases<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>

<span class="pl-c"><span class="pl-c">#</span> Incorrect</span>
curl -XGET localhost:9200/_aliases/myalias<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "bar" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>   },</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>


<span class="pl-c"><span class="pl-c">#</span> Correct</span>
curl -XGET localhost:9200/_alias<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "bar" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>   },</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>

<span class="pl-c"><span class="pl-c">#</span> Correct</span>
curl -XGET localhost:9200/foo/_alias<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>

<span class="pl-c"><span class="pl-c">#</span> Correct</span>
curl -XGET localhost:9200/_alias/myalias<span class="pl-k">?</span>pretty
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span>   "foo" : {</span>
<span class="pl-c"><span class="pl-c">#</span>     "aliases" : {</span>
<span class="pl-c"><span class="pl-c">#</span>       "myalias" : { }</span>
<span class="pl-c"><span class="pl-c">#</span>     }</span>
<span class="pl-c"><span class="pl-c">#</span>   }</span>
<span class="pl-c"><span class="pl-c">#</span> }</span></pre></div>
<p dir="auto">We don't document <code class="notranslate">GET _aliases</code> anymore so may be we should remove its support as we can do the same thing with <code class="notranslate">GET _alias</code> API.</p>
<p dir="auto">Might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="25672241" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/4743" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/4743/hovercard" href="https://github.com/elastic/elasticsearch/issues/4743">#4743</a><br>
Related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="125363831" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch-js/issues/331" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch-js/issues/331/hovercard" href="https://github.com/elastic/elasticsearch-js/issues/331">elastic/elasticsearch-js#331</a></p>
<p dir="auto">While working on removing <code class="notranslate">ImmutableMap</code> and <code class="notranslate">ImmutableSet</code> I've seen a ton of different fun ways to read immutable maps, sets, and lists. If we're willing to use Java 8's function pointer things we could remove lots of duplicated code by creating <code class="notranslate">readMap</code>, <code class="notranslate">readSet</code>, and <code class="notranslate">readList</code> in <code class="notranslate">StreamInput</code>. We could probably also do something similar for writing these but I haven't thought as much about it.</p>