Commit c049b5e3 authored by Samuel Trégouët's avatar Samuel Trégouët
Browse files

add all-in-one variable to configure indexable etypes

parent a0fa54761a3d
......@@ -63,6 +63,8 @@ class IndexInES(Command):
if es:
if self.config.etypes:
etypes = self.config.etypes
elif cnx.vreg.config['indexable-etypes']:
etypes = cnx.vreg.config['indexable-etypes']
else:
etypes = indexable_types(schema,
custom_skip_list=self.config.except_etypes)
......
......@@ -43,6 +43,11 @@ class ContentUpdateIndexES(hook.Hook):
category = 'es'
def __call__(self):
indexable_etypes = self._cw.vreg.config['indexable-etypes']
if indexable_etypes:
if self.entity.cw_etype in indexable_etypes:
IndexEsOperation.get_instance(self._cw).add_data(self.entity)
return
if self.entity.cw_etype == 'File':
return # FIXME hack!
IndexEsOperation.get_instance(self._cw).add_data(self.entity)
......@@ -62,6 +67,11 @@ class RelationsUpdateIndexES(hook.Hook):
cw_etype = entity.cw_etype
if cw_etype == 'File':
return # FIXME hack!
indexable_etypes = self._cw.vreg.config['indexable-etypes']
if indexable_etypes:
if entity.cw_etype in indexable_etypes:
IndexEsOperation.get_instance(self._cw).add_data(entity)
continue
if (cw_etype in indexable_types(entity._cw.vreg.schema) or
cw_etype in CUSTOM_ATTRIBUTES):
IndexEsOperation.get_instance(self._cw).add_data(entity)
......
options = (
('indexable-etypes',
{'type': 'csv',
'default': '',
'help': 'comma separated list of entity types to consider when indexing '
'with index-in-es command and from `es` hooks ',
'group': 'elasticsearch',
'level': 5,
}),
('elasticsearch-locations',
{'type': 'string',
'default': '',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment