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']
评论列表
文章目录