本文整理汇总了Python中nefertari.elasticsearch.ES.bulk_index_relations方法的典型用法代码示例。如果您正苦于以下问题:Python ES.bulk_index_relations方法的具体用法?Python ES.bulk_index_relations怎么用?Python ES.bulk_index_relations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nefertari.elasticsearch.ES
的用法示例。
在下文中一共展示了ES.bulk_index_relations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_bulk_delete
# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import bulk_index_relations [as 别名]
def on_bulk_delete(model_cls, objects, request):
if not getattr(model_cls, '_index_enabled', False):
return
pk_field = model_cls.pk_field()
ids = [getattr(obj, pk_field) for obj in objects]
from nefertari.elasticsearch import ES
es = ES(source=model_cls.__name__)
es.delete(ids, request=request)
# Reindex relationships
es.bulk_index_relations(objects, request=request)
示例2: on_bulk_update
# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import bulk_index_relations [as 别名]
def on_bulk_update(model_cls, objects, request):
if not getattr(model_cls, '_index_enabled', False):
return
if not objects:
return
from nefertari.elasticsearch import ES
es = ES(source=model_cls.__name__)
documents = to_dicts(objects)
es.index(documents, request=request)
# Reindex relationships
es.bulk_index_relations(objects, request=request, nested_only=True)
示例3: on_bulk_update
# 需要导入模块: from nefertari.elasticsearch import ES [as 别名]
# 或者: from nefertari.elasticsearch.ES import bulk_index_relations [as 别名]
def on_bulk_update(update_context):
request = getattr(
update_context.query, '_request', None)
model_cls = update_context.mapper.entity
if not getattr(model_cls, '_index_enabled', False):
return
objects = update_context.query.all()
if not objects:
return
from nefertari.elasticsearch import ES
es = ES(source=model_cls.__name__)
es.index(objects, request=request)
# Reindex relationships
es.bulk_index_relations(objects, request=request, nested_only=True)