Exemple #1
0
 def update_index(self):
     for entity_type in model.refs.TYPES:
         if hasattr(entity_type, "all"):
             for entity in entity_type.all():
                 index.update(entity)
     flash(_('Solr index updated.'), 'success')
     redirect(base_url('/admin'))
Exemple #2
0
 def update_index(self):
     for entity_type in model.refs.TYPES:
         if hasattr(entity_type, "all"):
             for entity in entity_type.all():
                 index.update(entity)
     flash(_('Solr index updated.'), 'success')
     redirect(base_url('/admin'))
Exemple #3
0
 def update_index(self):
     for entity_type in model.refs.TYPES:
         if hasattr(entity_type, "all"):
             for entity in entity_type.all():
                 index.update(entity)
     flash(_("Solr index updated."), "success")
     redirect(base_url("/admin"))
Exemple #4
0
def rebuild(classes):
    '''
    (Re)Index all entities of the given *classes*.
    '''
    start = time.time()
    done = 0
    connection = index.get_connection()
    for cls in classes:
        if cls not in INDEXED_CLASSES:
            log.warn('Class "%s" is not an indexable class! skipping.' % cls)
            continue
        log.info("Re-indexing %ss..." % cls.__name__)
        for entity in model.meta.Session.query(cls):
            index.update(entity, connection=connection, commit=False)
            done = done + 1
            if done % 100 == 0:
                connection.commit()
                log.info('indexed %d in %ss' % (done, time.time() - start))
    connection.commit()
    connection.close()
Exemple #5
0
def rebuild(classes):
    '''
    (Re)Index all entities of the given *classes*.
    '''
    start = time.time()
    done = 0
    connection = index.get_connection()
    for cls in classes:
        if cls not in INDEXED_CLASSES:
            log.warn('Class "%s" is not an indexable class! skipping.' %
                     cls)
            continue
        log.info("Re-indexing %ss..." % cls.__name__)
        for entity in model.meta.Session.query(cls):
            index.update(entity, connection=connection, commit=False)
            done = done + 1
            if done % 100 == 0:
                connection.commit()
                log.info('indexed %d in %ss' % (done, time.time() - start))
    connection.commit()
    connection.close()