<p dir="auto"><strong>Elasticsearch version</strong>: 2.2.0</p>
<p dir="auto"><strong>JVM version</strong>: 1.8.0_74</p>
<p dir="auto"><strong>OS version</strong>: 3.13.0-74-generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="165835" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/118" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/118/hovercard" href="https://github.com/elastic/elasticsearch/issues/118">#118</a>-Ubuntu SMP (Ubuntu Server 14.04 LTS)</p>
<p dir="auto"><strong>Elasticsearch Client</strong>: <a href="https://github.com/elastic/elasticsearch-py">elasticsearch-py</a></p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:<br>
I am trying to add aliases with filters to some indexes. Basically I have write and read aliases on an index, with filter and routing specified. Based on some criteria, I need to modify the aliases to point to a new index, at which time, I remove the write alias from the existing index, move it to the newly created index and at the same add the same read alias to the newly created index. I am using update_aliases api in the python client to perform all three operations atomically.</p>
<p dir="auto"><em>Expected behaviour</em>: The write alias should be removed from the old index and start pointing to the new index, while containing the filter and routing specified.</p>
<p dir="auto"><em>Observed behaviour</em>: The write alias is removed from the old index, added to the new index but doesnt contain the specified filter. Attaching code snippets in steps to reproduce.</p>
<p dir="auto"><strong>Steps to reproduce</strong>:</p>
<ul dir="auto">
<li>Apply alias actions:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="actions = {}
actions['actions'] = [{'remove': {'index': u'goibibo_201612', 'alias': u'w_goibibo-serviceresponsesuccess_201612'}}, {'add': {'filter': {'term': {'primaryName': u'goibibo-serviceresponsesuccess'}}, 'index': u'goibibo-serviceresponsesuccess_201612', 'alias': u'w_goibibo-serviceresponsesuccess_201612'}}, {'add': {'filter': {'term': {'primaryName': u'goibibo-serviceresponsesuccess'}}, 'index': u'goibibo-serviceresponsesuccess_201612', 'alias': u'r_goibibo-serviceresponsesuccess_201612'}}]
es.indices.update_aliases(body=actions)"><pre class="notranslate"><code class="notranslate">actions = {}
actions['actions'] = [{'remove': {'index': u'goibibo_201612', 'alias': u'w_goibibo-serviceresponsesuccess_201612'}}, {'add': {'filter': {'term': {'primaryName': u'goibibo-serviceresponsesuccess'}}, 'index': u'goibibo-serviceresponsesuccess_201612', 'alias': u'w_goibibo-serviceresponsesuccess_201612'}}, {'add': {'filter': {'term': {'primaryName': u'goibibo-serviceresponsesuccess'}}, 'index': u'goibibo-serviceresponsesuccess_201612', 'alias': u'r_goibibo-serviceresponsesuccess_201612'}}]
es.indices.update_aliases(body=actions)
</code></pre></div>
<ul dir="auto">
<li>Fetch alias (should contain the filter, but doesnt)</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="es.indices.get_alias(name='w_goibibo-serviceresponsesuccess_201612')

{u'goibibo-serviceresponsesuccess_201612': {u'aliases': {u'w_goibibo-serviceresponsesuccess_201612': {}}}}"><pre class="notranslate"><code class="notranslate">es.indices.get_alias(name='w_goibibo-serviceresponsesuccess_201612')

{u'goibibo-serviceresponsesuccess_201612': {u'aliases': {u'w_goibibo-serviceresponsesuccess_201612': {}}}}
</code></pre></div>
<p dir="auto"><strong>Provide logs (if relevant)</strong>:<br>
Didn't see any error logs in master node</p>
<p dir="auto">This started to occur in ES v2.2.0. Easy steps to repro:</p>
<ol dir="auto">
<li>Crete and index</li>
<li>Put an alias</li>
<li>Display the alias</li>
<li>Check that the filter is not presented</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
PUT test_index
{
  &quot;mappings&quot;: {
    &quot;document_type&quot;: {
      &quot;properties&quot;: {
        &quot;tags&quot;: {
          &quot;type&quot;: &quot;string&quot;,
          &quot;index&quot;: &quot;not_analyzed&quot;,
          &quot;fields&quot;: {
            &quot;analyzed&quot;: {
              &quot;type&quot;: &quot;string&quot;
            }
          },
          &quot;ignore_above&quot;: 256
        }
      }
    }
  }
}

POST /_aliases
{
  &quot;actions&quot;: [
    {
      &quot;add&quot;: {
        &quot;index&quot;: &quot;test_in*&quot;, &lt;----- with wildcards
        &quot;alias&quot;: &quot;test_index_filter&quot;,
        &quot;filter&quot;: {
          &quot;term&quot;: {
            &quot;tags&quot;: &quot;customerconsent&quot;
          }
        }
      }
    }
  ]
}

OR

POST /_aliases
{
  &quot;actions&quot;: [
    {
      &quot;add&quot;: {
        &quot;index&quot;: &quot;test_index&quot;,     &lt;------ without wildcards 
        &quot;alias&quot;: &quot;test_index_filter&quot;,
        &quot;filter&quot;: {
          &quot;term&quot;: {
            &quot;tags&quot;: &quot;customerconsent&quot;
          }
        }
      }
    }
  ]
}

GET _aliases"><pre class="notranslate"><code class="notranslate">
PUT test_index
{
  "mappings": {
    "document_type": {
      "properties": {
        "tags": {
          "type": "string",
          "index": "not_analyzed",
          "fields": {
            "analyzed": {
              "type": "string"
            }
          },
          "ignore_above": 256
        }
      }
    }
  }
}

POST /_aliases
{
  "actions": [
    {
      "add": {
        "index": "test_in*", &lt;----- with wildcards
        "alias": "test_index_filter",
        "filter": {
          "term": {
            "tags": "customerconsent"
          }
        }
      }
    }
  ]
}

OR

POST /_aliases
{
  "actions": [
    {
      "add": {
        "index": "test_index",     &lt;------ without wildcards 
        "alias": "test_index_filter",
        "filter": {
          "term": {
            "tags": "customerconsent"
          }
        }
      }
    }
  ]
}

GET _aliases
</code></pre></div>
<p dir="auto">Result</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;test_index&quot;: {
    &quot;aliases&quot;: {
      &quot;test_index_filter&quot;: {}
    }
  }
}"><pre class="notranslate"><code class="notranslate">{
  "test_index": {
    "aliases": {
      "test_index_filter": {}
    }
  }
}
</code></pre></div>