import_data.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:find-that-charity 作者: TechforgoodCAST 项目源码 文件源码
def fetch_postcode(postcode, es, es_index="postcode", es_type="postcode"):
    if postcode is None:
        return None

    areas = ["hro", "wz11", "bua11", "pct", "lsoa11", "nuts", "msoa11", "laua",
             "oa11", "ccg", "ward", "teclec", "gor", "ttwa", "pfa", "pcon",
             "lep1", "cty", "eer", "ctry", "park", "lep2", "hlthau", "buasd11"]
    try:
        res = es.get(index=es_index, doc_type=es_type,
                     id=postcode, ignore=[404])
        if res['found']:
            return (res['_source'].get("location"),
                    {k: res['_source'].get(k) for
                     k in res['_source'] if k in areas})
    except (NotFoundError, ValueError):
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号