Beispiel #1
0
def send_chunks_to_es(chunker, elasticsearch=None, callback=None):
    """ limits the cpu bound task of serializing high quantities of django models
    by serializing small chunks and sending them to elasticsearch
    """
    send_chunk = partial(es_bulk_op,
                         elasticsearch or connect(),
                         chunk_size=chunker.chunk_size)

    for chunk in chunker:
        result = send_chunk(chunk)
        if callable(callback):
            callback(result)
def send_chunks_to_es(chunker, elasticsearch=None, callback=None):
    """ limits the cpu bound task of serializing high quantities of django models
    by serializing small chunks and sending them to elasticsearch
    """
    send_chunk = partial(es_bulk_op,
        elasticsearch or connect(),
        chunk_size=chunker.chunk_size)

    for chunk in chunker:
        result = send_chunk(chunk)
        if callable(callback):
            callback(result)
    def setUp(self):
        self.elastic = connect()
        self.instance_default = TestModelA(
            test_char="hello, world", test_int=24,
            test_float=3.1415927)
        self.instance_default_2 = TestModelB(
            test_char="hello, world", test_int=24,
            test_float=3.1415927)

        self.aindex = TestModelA._search_meta.index_name
        self.adoctype = TestModelA._search_meta.doctype_name
        self.bindex = TestModelB._search_meta.index_name
        self.bdoctype = TestModelB._search_meta.doctype_name
    def setUp(self):
        self.elastic = connect()
        self.instance_default = TestModelA(test_char="hello, world",
                                           test_int=24,
                                           test_float=3.1415927)
        self.instance_default_2 = TestModelB(test_char="hello, world",
                                             test_int=24,
                                             test_float=3.1415927)

        self.aindex = TestModelA._search_meta.index_name
        self.adoctype = TestModelA._search_meta.doctype_name
        self.bindex = TestModelB._search_meta.index_name
        self.bdoctype = TestModelB._search_meta.doctype_name
Beispiel #5
0
 def _get_es(self):
     from elasticmodels import connect
     if not self._elastic:
         self._elastic = connect()
     return self._elastic
    def _get_es(self):
        from elasticmodels import connect

        if not self._elastic:
            self._elastic = connect()
        return self._elastic