示例#1
0
    def bulk(self, actions, refresh=False, **kw):
        """Use the Elasticsearch library's ``bulk()`` helper function to process
        documents en masse.

        Equivalent to the legacy ``ElasticsearchInterface.bulk_ops(...)``
        method.

        :param actions: iterable of ``BulkActionItem`` instances
        :param refresh: ``bool`` refresh the effected shards to make this
                        operation visible to search
        :param **kw: extra parameters passed directly to the underlying
                     ``elasticsearch.helpers.bulk()`` function.
        """
        payload = [self._render_bulk_action(action) for action in actions]
        return bulk(self._es, payload, refresh=self._refresh_value(refresh), **kw)
示例#2
0
 def bulk_ops(self, actions, stats_only=False, **kwargs):
     for action in actions:
         if '_source' in action:
             action['_source'] = self._without_id_field(action['_source'])
     ret = bulk(self.es, actions, stats_only=stats_only, **kwargs)
     return ret