本文整理匯總了Python中nefertari.elasticsearch.ES.index_relations方法的典型用法代碼示例。如果您正苦於以下問題:Python ES.index_relations方法的具體用法?Python ES.index_relations怎麽用?Python ES.index_relations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nefertari.elasticsearch.ES
的用法示例。
在下文中一共展示了ES.index_relations方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_after_delete
# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_relations [as 別名]
def on_after_delete(mapper, connection, target):
from nefertari.elasticsearch import ES
request = getattr(target, '_request', None)
model_cls = target.__class__
es = ES(model_cls.__name__)
obj_id = getattr(target, model_cls.pk_field())
es.delete(obj_id, request=request)
es.index_relations(target, request=request)
示例2: on_post_save
# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_relations [as 別名]
def on_post_save(sender, document, **kw):
""" Add new document to index or update existing. """
from nefertari.elasticsearch import ES
common_kw = {'request': getattr(document, '_request', None)}
created = kw.get('created', False)
if created:
es = ES(document.__class__.__name__)
es.index(document.to_dict(), **common_kw)
elif not created and document._get_changed_fields():
es = ES(document.__class__.__name__)
es.index(document.to_dict(), **common_kw)
es.index_relations(document, nested_only=True, **common_kw)
示例3: index_object
# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_relations [as 別名]
def index_object(obj, with_refs=True, **kwargs):
from nefertari.elasticsearch import ES
es = ES(obj.__class__.__name__)
es.index(obj.to_dict(), **kwargs)
if with_refs:
es.index_relations(obj, **kwargs)
示例4: index_object
# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import index_relations [as 別名]
def index_object(obj, with_refs=True, **kwargs):
es = ES(obj.__class__.__name__)
es.index(obj, **kwargs)
if with_refs:
es.index_relations(obj, **kwargs)