Add explicit full-text indexing on creation if massive store is used
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 Oct 2016 13:59:23 +0200
changeset 1946 b73e68a968a9
parent 1945 577f41dceb9f
child 1947 bc3703b8278f
Add explicit full-text indexing on creation if massive store is used since it doesn't handle that.
dataimport.py
--- a/dataimport.py	Thu Oct 20 08:51:14 2016 +0200
+++ b/dataimport.py	Thu Oct 20 13:59:23 2016 +0200
@@ -23,6 +23,8 @@
 
 from six import text_type
 
+from cubicweb.server.checkintegrity import reindex_entities
+from cubicweb.dataimport.stores import NoHookRQLObjectStore
 from cubicweb.dataimport.importer import SimpleImportLog
 
 from cubes.skos import lcsv, sobjects as skos
@@ -123,7 +125,6 @@
         from cubicweb.dataimport.massive_store import MassiveObjectStore
         return MassiveObjectStore(cnx, eids_seq_range=1000)
     else:
-        from cubicweb.dataimport.stores import NoHookRQLObjectStore
         return NoHookRQLObjectStore(cnx)
 
 
@@ -149,6 +150,9 @@
             store.flush()
     store.commit()
     store.finish()
+    if not isinstance(store, NoHookRQLObjectStore):
+        # when using the massive store, we need explicit reindexation
+        reindex_entities(cnx.repo.schema, cnx, etypes=['Concept', 'ConceptScheme'])
 
 
 # hack to avoid recomputing extid2eid mapping for each lcsv file, this is costly with massive store