當前位置: 首頁>>代碼示例>>Python>>正文


Python ES.get_collection方法代碼示例

本文整理匯總了Python中nefertari.elasticsearch.ES.get_collection方法的典型用法代碼示例。如果您正苦於以下問題:Python ES.get_collection方法的具體用法?Python ES.get_collection怎麽用?Python ES.get_collection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nefertari.elasticsearch.ES的用法示例。


在下文中一共展示了ES.get_collection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getitem_es

# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import get_collection [as 別名]
 def getitem_es(self, key):
     """ Get item with ID of :key: from elasticsearch """
     from nefertari.elasticsearch import ES
     es = ES(self.__context_class__.__name__)
     pk_field = self.__context_class__.pk_field()
     kwargs = {
         pk_field: key,
         '_limit': 1,
         '__raise_on_empty': True,
     }
     obj = es.get_collection(**kwargs)[0]
     obj.__acl__ = self.context_acl(obj)
     obj.__parent__ = self
     obj.__name__ = key
     return obj
開發者ID:gitter-badger,項目名稱:ramses,代碼行數:17,代碼來源:acl.py

示例2: get_collection_es

# 需要導入模塊: from nefertari.elasticsearch import ES [as 別名]
# 或者: from nefertari.elasticsearch.ES import get_collection [as 別名]
    def get_collection_es(self, **kwargs):
        """ Get ES objects collection taking into account the generated
        queryset of parent view.

        This method allows working with nested resources properly. Thus a
        queryset returned by this method will be a subset of its parent view's
        queryset, thus filtering out objects that don't belong to the parent
        object.
        """
        from nefertari.elasticsearch import ES
        es = ES(self.Model.__name__)
        objects_ids = self._parent_queryset_es()

        if objects_ids is not None:
            objects_ids = self.get_es_object_ids(objects_ids)

            if not objects_ids:
                return []
            self._query_params['id'] = objects_ids
        return es.get_collection(
            _raw_terms=self._get_raw_terms(),
            **self._query_params)
開發者ID:gitter-badger,項目名稱:ramses,代碼行數:24,代碼來源:views.py


注:本文中的nefertari.elasticsearch.ES.get_collection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。