boto を使って Python で検索 習作

#!/bin/env python
# -*- coding: utf-8 -*-

from boto.cloudsearch2.layer2 import Layer2

layer2 = Layer2( aws_access_key_id='aws_access_key_id',
 aws_secret_access_key='aws_secret_access_key',
 region='ap-northeast-1')

domain = layer2.lookup('ドメイン名')
search_service = domain.get_search_service()
results = search_service.search(q="夏目漱石")

print results.hits

for doc in results:
 print '----------'
 for k, v in doc.items():
  if k == 'id' :
   print k, v
  else:
   for k2, v2, in v.items():
    if k2 == 'title':
     print k2, v2