diff --git a/hooks.py b/hooks.py index 848960dc68c1797b393a229937caf3ca33b5294a_aG9va3MucHk=..bf904074747b5d0df79b2824e5d13277a286242c_aG9va3MucHk= 100644 --- a/hooks.py +++ b/hooks.py @@ -24,9 +24,9 @@ from cubicweb.server import hook from cubicweb.predicates import score_entity -from cubes.elasticsearch.es import indexable_types, fulltext_indexable_rql, get_connection +from cubes.elasticsearch.es import indexable_types, fulltext_indexable_rql, CUSTOM_ATTRIBUTES log = logging.getLogger(__name__) def entity_indexable(entity): @@ -28,9 +28,10 @@ log = logging.getLogger(__name__) def entity_indexable(entity): - return entity.cw_etype in indexable_types(entity._cw.vreg.schema) + return entity.cw_etype in indexable_types(entity._cw.vreg.schema) or \ + entity.cw_etype in CUSTOM_ATTRIBUTES class ContentUpdateIndexES(hook.Hook): @@ -45,7 +46,8 @@ def __call__(self): if self.entity.cw_etype == 'File': return # FIXME hack! - es = get_connection(self._cw.vreg.config) + indexer = self.entity._cw.vreg['es'].select('indexer', self.entity._cw) + es = indexer.get_connection() if es: rql = fulltext_indexable_rql(self.entity.cw_etype, self.entity._cw.vreg.schema,