Support Center
ElasticSearch connections created in Dashboard allow one to index, look up or delete stored documents and access other features ElasticSearch itself offers.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
conn = self.search.es.get('My Connection').conn
# Create a document
conn.create('my-idx', 'my-type', {'hello':'world'}, 'my-id')
In server.log:
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
conn = self.search.es.get('My Connection').conn
# Look up documents using ES syntax
result = conn.search(q='hello:*')
# Iterate over what ES gave us
for item in result:
self.logger.info(result)
In server.log:
INFO - GET http://es:9200/_search?q=hello%3A%2A [status:200 request:0.058s]
INFO - {'hits': {'hits': [{'_score': 1.0, '_type': 'my-type', '_id': 'my-id' ..
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
conn = self.search.es.get('My Connection').conn
# Delete a document by its ID
conn.delete('my-idx', 'my-type', 'my-id')
In server.log:
The connection object is an instance of elasticsearch.client.Elasticsearch. Refer to its main documentation in order to learn how to access other features such as bulk deleting, counting and more.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
conn = self.search.es.get('My Connection').conn
self.logger.info(conn.__class__)
Book a demo with an expert who will help you build meaningful systems that match your ambitions
"For me, Zato Source is the only technology partner to help with operational improvements."