[es] better escaping of index checking, only if index-name is not None (related #17049617)

authorArthur Lutz <arthur.lutz@logilab.fr>
changesete6db12c7be33
branchdefault
phasepublic
hiddenno
parent revision#155a20154f84 [tox] add mock test dependency
child revision#5e539ec0c9b5 [views] add max pagination (avoid elasticsearch crash) (closes #17049617)
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 e6db12c7be3355f705dedfcc39329c1b85850200
# Parent 155a20154f844efa5436f26b5b092c9ee17027e1
[es] better escaping of index checking, only if index-name is not None (related #17049617)

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