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

authorArthur Lutz <arthur.lutz@logilab.fr>
changeset72b26fb04f0d
branchdefault
phasedraft
hiddenyes
parent revision#28d3fa93cb9e [tox] add mock test dependency
child revision#6d4a71087fb1 [facet] add `cw_etype_label` entry to be displaed as cw_etype facet label (related #13455788), #5b23bcf3be29 [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 72b26fb04f0de0397b5762bcc6cb6bfd0f78bb70
# Parent 28d3fa93cb9e270c56529f487312fb8a8282cef3
[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