# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1464953882 -7200 # Fri Jun 03 13:38:02 2016 +0200 # Node ID fce27a9be2dcbac066e93f4d5e60ca24cb823ece # Parent 049c2ebd2212ade7d0a91b3ac7a4d857b2c306e2 [hooks] create index on hooks if it doesn't exist diff --git a/hooks.py b/hooks.py --- a/hooks.py +++ b/hooks.py @@ -49,10 +49,15 @@ locations = self._cw.vreg.config['elasticsearch-locations'] index_name = self._cw.vreg.config['index-name'] if locations and index_name: + es = Elasticsearch(locations and locations.split(',')) + # TODO : have a cache so that we don't check index on every transition + if not es.indices.exists(index=index_name): + es.indices.create(index=index_name, + body=INDEX_SETTINGS, + ignore=400) # serializer = self.entity.cw_adapt_to('IFTISerializable') serializer = self.entity.cw_adapt_to('ISerializable') json = serializer.serialize() - es = Elasticsearch(locations and locations.split(',')) try: # TODO option pour coté async ? es.index(index=index_name,