Page MenuHomec4science

esoperations.py
No OneTemporary

File Metadata

Created
Tue, May 7, 08:04

esoperations.py

# © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE,
# Switzerland
# SCITAS - Scientific IT and Application Support, 2021
# See the LICENSE.txt file for more details.
import importlib
for mname in ['elasticsearch', 'elasticsearch6']:
es_spec = importlib.util.find_spec(mname)
if es_spec is not None:
esmodule = importlib.import_module(mname)
break
class ESOp:
def __init__(self, server):
self.server = esmodule.Elasticsearch([server])
def esget(self, index, doc):
try:
response = self.server.search(index=index, body=doc)
return response
except BaseException:
return ""

Event Timeline