# HG changeset patch # User Samuel Trégouët <samuel.tregouet@logilab.fr> # Date 1485364778 -3600 # Wed Jan 25 18:19:38 2017 +0100 # Node ID ac5f8d85cf00f9cbc9a6b544b75d4161182c1a9d # Parent 418cc00ec3e8e9d151e66663e976d1fd20e436d5 easy customization of index-name diff --git a/entities.py b/entities.py --- a/entities.py +++ b/entities.py @@ -60,12 +60,16 @@ } } + @property + def index_name(self): + return self._cw.vreg.config['index-name'] + def get_connection(self): self.create_index() return es.get_connection(self._cw.vreg.config) def create_index(self, index_name=None, custom_settings=None): - index_name = index_name or self._cw.vreg.config['index-name'] + index_name = index_name or self.index_name if custom_settings is None: settings = self.settings else: diff --git a/hooks.py b/hooks.py --- a/hooks.py +++ b/hooks.py @@ -66,7 +66,7 @@ json = serializer.serialize() try: # TODO option pour coté async ? thread - kwargs = dict(index=self.cnx.vreg.config['index-name'], + kwargs = dict(index=indexer.index_name, id=entity.eid, doc_type=entity.cw_etype, body=json)