This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new eae2bb7 Oops, indices interface is used after all
eae2bb7 is described below
commit eae2bb77f9a2889973e480e1d8baa1485fa1d1d9
Author: Sebb <[email protected]>
AuthorDate: Fri Nov 12 21:46:09 2021 +0000
Oops, indices interface is used after all
---
tools/mappings.py | 4 ++--
tools/plugins/elastic.py | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/mappings.py b/tools/mappings.py
index d38b0c5..28e0e69 100755
--- a/tools/mappings.py
+++ b/tools/mappings.py
@@ -38,7 +38,7 @@ if major != 7:
sys.exit(-1)
# actual mappings
-mappings =
elastic.get_mapping(index=elastic.db_mbox)[elastic.db_mbox]['mappings']['properties']
+mappings =
elastic.indices.get_mapping(index=elastic.db_mbox)[elastic.db_mbox]['mappings']['properties']
if mappings == mapping_file:
print("Mappings are as expected, hoorah!")
@@ -51,4 +51,4 @@ else:
for name in expected:
data = {name: mapping_file[name]}
print("Missing: " + str(data))
- elastic.put_mapping(body={'properties': data}, index=elastic.db_mbox)
+ elastic.indices.put_mapping(body={'properties': data},
index=elastic.db_mbox)
diff --git a/tools/plugins/elastic.py b/tools/plugins/elastic.py
index 7ad0403..4681959 100755
--- a/tools/plugins/elastic.py
+++ b/tools/plugins/elastic.py
@@ -108,6 +108,9 @@ class Elastic:
else:
raise Exception("Unexpected elasticsearch version ",
es_engine_major)
+ # Mimic ES hierarchy: es.indices.xyz()
+ self.indices = _indices_wrap(self)
+
@staticmethod
def libraryVersion():
return ES_VERSION
@@ -190,6 +193,16 @@ class Elastic:
when terminating scrolling early.
"""
return self.es.clear_scroll(*args, **kwargs)
+class _indices_wrap:
+ """
+ Wrapper for the ES indices methods we use
+ """
+
+ def __init__(self, parent):
+ self.es = parent.es
+
+ def exists(self, *args, **kwargs):
+ return self.es.indices.exists(*args, **kwargs)
def get_mapping(self, **kwargs):
return self.es.indices.get_mapping(**kwargs)