本文整理汇总了Python中opencontext_py.apps.entities.entity.models.Entity.search方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.search方法的具体用法?Python Entity.search怎么用?Python Entity.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opencontext_py.apps.entities.entity.models.Entity
的用法示例。
在下文中一共展示了Entity.search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: look_up
# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import search [as 别名]
def look_up(request, item_type):
""" Returns JSON data for entities
limited by certain criteria
"""
ent = Entity()
qstring = ''
class_uri = False
project_uuid = False
vocab_uri = False
ent_type = False
context_uuid = False
data_type = False
context = False
if len(item_type) < 2:
item_type = False
if 'q' in request.GET:
qstring = request.GET['q']
if 'class_uri' in request.GET:
class_uri = request.GET['class_uri']
if 'project_uuid' in request.GET:
project_uuid = request.GET['project_uuid']
if 'vocab_uri' in request.GET:
vocab_uri = request.GET['vocab_uri']
if 'ent_type' in request.GET:
ent_type = request.GET['ent_type']
if 'context_uuid' in request.GET:
context_uuid = request.GET['context_uuid']
if 'data_type' in request.GET:
data_type = request.GET['data_type']
if 'context' in request.GET:
context = request.GET['context']
entity_list = ent.search(qstring,
item_type,
class_uri,
project_uuid,
vocab_uri,
ent_type,
context_uuid,
data_type,
context)
json_output = json.dumps(entity_list,
indent=4,
ensure_ascii=False)
return HttpResponse(json_output,
content_type='application/json; charset=utf8')