server/checkintegrity.py
branchstable
changeset 4816 c02583cb80a9
parent 4806 4f12f59b1a13
child 4831 c5aec27c1bf7
equal deleted inserted replaced
4815:4ee224c4c41d 4816:c02583cb80a9
    66 
    66 
    67 def reindex_entities(schema, session, withpb=True):
    67 def reindex_entities(schema, session, withpb=True):
    68     """reindex all entities in the repository"""
    68     """reindex all entities in the repository"""
    69     # deactivate modification_date hook since we don't want them
    69     # deactivate modification_date hook since we don't want them
    70     # to be updated due to the reindexation
    70     # to be updated due to the reindexation
    71     from cubicweb.server.repository import FTIndexEntityOp
       
    72     repo = session.repo
    71     repo = session.repo
    73     cursor = session.pool['system']
    72     cursor = session.pool['system']
    74     if not repo.system_source.indexer.has_fti_table(cursor):
    73     if not repo.system_source.indexer.has_fti_table(cursor):
    75         from indexer import get_indexer
    74         from indexer import get_indexer
    76         print 'no text index table'
    75         print 'no text index table'
   102     session.system_sql('DELETE FROM %s' % session.repo.system_source.dbhelper.fti_table)
   101     session.system_sql('DELETE FROM %s' % session.repo.system_source.dbhelper.fti_table)
   103     if withpb:
   102     if withpb:
   104         pb.update()
   103         pb.update()
   105     # reindex entities by generating rql queries which set all indexable
   104     # reindex entities by generating rql queries which set all indexable
   106     # attribute to their current value
   105     # attribute to their current value
       
   106     source = repo.system_source
   107     for eschema in etypes:
   107     for eschema in etypes:
   108         for entity in session.execute('Any X WHERE X is %s' % eschema).entities():
   108         for entity in session.execute('Any X WHERE X is %s' % eschema).entities():
   109             FTIndexEntityOp(session, entity=entity)
   109             source.fti_unindex_entity(session, entity.eid)
       
   110             source.fti_index_entity(session, entity)
   110         if withpb:
   111         if withpb:
   111             pb.update()
   112             pb.update()
   112     # restore Entity.check
   113     # restore Entity.check
   113     Entity.check = _check
   114     Entity.check = _check
   114     repo.config.disabled_hooks_categories.remove('metadata')
   115     repo.config.disabled_hooks_categories.remove('metadata')