def state_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.cluster_state, **{ 'metric': args.metric, 'index': args.index }) print(s.body.rstrip('\n'))
def field_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.fielddata_cat, **{ 'fields': args.field, 'params': { 'v': True } }) print(s.body.rstrip('\n'))
def shards_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.shards_cat, **{ 'index': args.index, 'params': { 'v': True } }) print(s.body.rstrip('\n'))
def allocation_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.allocation_cat, **{ 'node_id': args.node_id, 'params': { 'v': True } }) print(s.body.rstrip('\n'))
def aliases_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.aliases_cat, **{ 'name': args.name, 'params': { 'v': True } }) print(s.body.rstrip('\n'))
def index_coro(args): if args.file == '-': data_file = sys.stdin else: data_file = open(args.file, 'r') c = EsClient(host=args.host, port=args.port) data = '%s\n' % ''.join(data_file.readlines()) s = yield gen.Task(c.bulk, data) print(s.body.rstrip('\n'))
def search_coro(args): c = EsClient(host=args.host, port=args.port) doc_type = ','.join(args.doc_type) if args.doc_type else None exclude = ','.join(args.exclude) if args.exclude else None explain = '_explain' if args.explain else None fields = ','.join(args.fields) if args.fields else None index = ','.join(args.index) if args.index else None s = yield gen.Task( c.search, **{ 'params': { 'default_operator': args.operator, 'doc_type': args.doc_type, 'explain': explain, 'from': args.start, 'index': args.index, 'q': args.query, 'size': args.size, '_source_exclude': args.exclude, '_source_include': fields, } }) print(s.body.rstrip('\n'))
from __future__ import print_function from elasticsearch_tornado import EsClient, serialize from functools import partial from tornado import ioloop, gen import json c = EsClient() @gen.coroutine def index(doc): p = partial( c.index_doc, 'test_index', 'test_doctype', serialize(doc), ) res = yield gen.Task(p) raise gen.Return(res) @gen.coroutine def get(doc_id): p = partial( c.get_doc, 'test_index', doc_id, ) res = yield gen.Task(p) raise gen.Return(res)
def stats_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.cluster_stats, **{'node_id': args.node_id}) print(s.body.rstrip('\n'))
def health_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.cluster_health) print(s.body.rstrip('\n'))
def plugins_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.plugins_cat, **{'params': {'v': True}}) print(s.body.rstrip('\n'))
def pending_coro(args): c = EsClient(host=args.host, port=args.port) s = yield gen.Task(c.pending_tasks_cat) print(s.body.rstrip('\n'))