elasticsearch.py 文件源码

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

项目:oclubs 作者: SHSIDers 项目源码 文件源码
def get(doc_type, doc_id, fields=True):
    """
    Get an Elasticsearch document.

    :param basestring doc_type: document type
    :param doc_id: document id, will be converted into basestring
    :param fields: if ``False``, returns whether the document is found as bool;
        if ``True``, returns the document dict; if list of string, returns the
        document dict with only the specified fields.
    :rtype: dict or bool
    """
    ret = es.get(
        index='oclubs',
        doc_type=doc_type,
        id=doc_id,
        _source=fields
    )

    if fields is not False:
        return ret['_source']
    else:
        return ret['found']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号