diff --git a/hooks.py b/hooks.py index 049c2ebd2212ade7d0a91b3ac7a4d857b2c306e2_aG9va3MucHk=..fce27a9be2dcbac066e93f4d5e60ca24cb823ece_aG9va3MucHk= 100644 --- a/hooks.py +++ b/hooks.py @@ -49,6 +49,12 @@ 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() @@ -52,7 +58,6 @@ # 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,