Skip to content
Snippets Groups Projects
Commit bf904074747b authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[hooks] use indexer from registration, also index types in CUSTOM_TYPES

parent 848960dc68c1
No related branches found
No related tags found
No related merge requests found
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
from cubicweb.server import hook from cubicweb.server import hook
from cubicweb.predicates import score_entity 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__) log = logging.getLogger(__name__)
def entity_indexable(entity): def entity_indexable(entity):
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def entity_indexable(entity): 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): class ContentUpdateIndexES(hook.Hook):
...@@ -45,7 +46,8 @@ ...@@ -45,7 +46,8 @@
def __call__(self): def __call__(self):
if self.entity.cw_etype == 'File': if self.entity.cw_etype == 'File':
return # FIXME hack! 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: if es:
rql = fulltext_indexable_rql(self.entity.cw_etype, rql = fulltext_indexable_rql(self.entity.cw_etype,
self.entity._cw.vreg.schema, self.entity._cw.vreg.schema,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment