[es] better escaping of index checking, only if index-name is not None

authorArthur Lutz <arthur.lutz@logilab.fr>
changesetef1ad2c7b298
branchdefault
phasedraft
hiddenyes
parent revision#155a20154f84 [tox] add mock test dependency
child revision#9251b14d9244 [views] add max pagination (avoid elasticsearch crash)
files modified by this revision
es.py
# HG changeset patch
# User Arthur Lutz <arthur.lutz@logilab.fr>
# Date 1484237056 -3600
# Thu Jan 12 17:04:16 2017 +0100
# Node ID ef1ad2c7b298d4371282df649b187e68e9e14d48
# Parent 155a20154f844efa5436f26b5b092c9ee17027e1
[es] better escaping of index checking, only if index-name is not None

diff --git a/es.py b/es.py
@@ -108,11 +108,11 @@
1      :settings:
2        mapping and analyzer definitions
3 
4      """
5      try:
6 -        if not es.indices.exists(index=index_name):
7 +        if index_name and not es.indices.exists(index=index_name):
8              es.indices.create(index=index_name,
9                                body=settings)
10      except (ConnectionError, ProtocolError):
11          log.debug('Failed to index in hook, could not connect to ES')
12