Q:

ElasticSearch - python alias type

I have a elasticsearch instance with zzz index and devices document type.  Devices have different manufacturers:
$ curl 'http://localhost:9200/zzz/devices/_search?pretty=true&q=*:*'

result:
{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 93,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "309",
        "_score": 1.0,
        "_source": {
          "title": "Apple iPad Air",
          "url": "http://admin.zzz:5000/api/devices/309",
          "images": [
            {
              "url": "http://images.zzz.co.uk/Pb_YD8-Apple-iPad-Air-Space-grey-front.png"
            }
          ],
          "model": "iPad Air",
          "type": "device",
          "id": 309,
          "manufacturer": {
            "id": 24,
            "name": "Apple"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "330",
        "_score": 1.0,
        "_source": {
          "title": "Apple iPad with Retina Display",
          "url": "http://admin.zzz:5000/api/devices/330",
          "images": [
            {
              "url": "http://images.zzz.co.uk/6F_UHO-Apple-iPad-Air-Space-grey-front.png"
            }
          ],
          "model": "iPad with Retina Display",
          "type": "device",
          "id": 330,
          "manufacturer": {
            "id": 24,
            "name": "Apple"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "1",
        "_score": 1.0,
        "_source": {
          "title": "Apple iPhone 5s",
          "url": "http://admin.zzz:5000/api/devices/1",
          "images": [
            {
              "url": "http://images.zzz.co.uk/fEcmFm-Apple-5S-Gold-front.png"
            },
            {
              "url": "http://images.zzz.co.uk/9RDYXY-Apple-5S-Gold-back.png"
            }
          ],
          "model": "iPhone 5s",
          "type": "device",
          "id": 1,
          "manufacturer": {
            "id": 24,
            "name": "Apple"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "335",
        "_score": 1.0,
        "_source": {
          "title": "Asus Fonepad",
          "url": "http://admin.zzz:5000/api/devices/335",
          "images": [
            {
              "url": "http://images.zzz.co.uk/oMOlgt-Asus-Fonepad-black.png"
            }
          ],
          "model": "Asus Fonepad",
          "type": "device",
          "id": 335,
          "manufacturer": {
            "id": 11,
            "name": "Asus Fonepad"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "328",
        "_score": 1.0,
        "_source": {
          "title": "HTC Desire 610",
          "url": "http://admin.zzz:5000/api/devices/328",
          "images": [
            {
              "url": "http://images.zzz.co.uk/QdavNt-HTC-610-Navy.png"
            }
          ],
          "model": "Desire 610",
          "type": "device",
          "id": 328,
          "manufacturer": {
            "id": 23,
            "name": "HTC"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "347",
        "_score": 1.0,
        "_source": {
          "title": "Huawei E5756",
          "url": "http://admin.zzz:5000/api/devices/347",
          "images": [
            {
              "url": "http://images.zzz.co.uk/mJjOiN-Huawei_E5756.png"
            }
          ],
          "model": "Huawei E5756",
          "type": "device",
          "id": 347,
          "manufacturer": {
            "id": 20,
            "name": "Huawei E5756"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "70",
        "_score": 1.0,
        "_source": {
          "title": "LG G2",
          "url": "http://admin.zzz:5000/api/devices/70",
          "images": [
            {
              "url": "http://images.zzz.co.uk/GnTFhn-LG-G2-Black-Front.png"
            }
          ],
          "model": "G2",
          "type": "device",
          "id": 70,
          "manufacturer": {
            "id": 5,
            "name": "LG"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "342",
        "_score": 1.0,
        "_source": {
          "title": "LG G3",
          "url": "http://admin.zzz:5000/api/devices/342",
          "images": [
            {
              "url": "http://images.zzz.co.uk/yH2HFE-Screen_Shot_2014-06-26_at_11.09.40.png"
            }
          ],
          "model": "LG G3",
          "type": "device",
          "id": 342,
          "manufacturer": {
            "id": 5,
            "name": "LG"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "304",
        "_score": 1.0,
        "_source": {
          "title": "LG Nexus 5",
          "url": "http://admin.zzz:5000/api/devices/304",
          "images": [
            {
              "url": "http://images.zzz.co.uk/PxLiur-LG-Nexus5-white-front.png"
            }
          ],
          "model": "Nexus 5",
          "type": "device",
          "id": 304,
          "manufacturer": {
            "id": 5,
            "name": "LG"
          }
        }
      },
      {
        "_index": "zzz",
        "_type": "devices",
        "_id": "114",
        "_score": 1.0,
        "_source": {
          "title": "Nokia Lumia 1020",
          "url": "http://admin.zzz:5000/api/devices/114",
          "images": [
            {
              "url": "http://images.zzz.co.uk/w0gk6L-Nokia-Lumia1020-yellow-front.png"
            }
          ],
          "model": "Lumia 1020",
          "type": "device",
          "id": 114,
          "manufacturer": {
            "id": 7,
            "name": "Nokia"
          }
        }
      }
    ]
  }
}

How can I create an alias for apple devices?  I've tried 
es.indices.put_alias(index="zzz", name="devices_apple", body={ 
        "routing" : "devices_apple",
        "filter" : {
            "term" : {
                "manufacturer.name" : "Apple"
            }
        }
    });

but http://localhost:9200/cbp/devices/devices_apple returns nothing.  
I'm very new to elasticsearch so any tips appreciated.  

A:

Try this:
es.indices.put_alias(index="zzz", name="devices_apple", body="""{ 
    "routing" : "devices_apple",
    "filter" : {
        "term" : {
            "manufacturer.name" : "Apple"
        }
    }
}""")

You can save the return value and print it.  If it worked it should contain"{'acknowledged': True}". 
You can also have a look here to see the changes: 'http://localhost:9200/zzz'.  Use a 'GET _aliases' request to see if there is any new aliases on the index.