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

[hooks] create index on hooks if it doesn't exist

parent 049c2ebd2212
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
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