Пример #1
0
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'))
Пример #2
0
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'))
Пример #3
0
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'))
Пример #4
0
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'))
Пример #5
0
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'))
Пример #6
0
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'))
Пример #7
0
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'))
Пример #8
0
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)
Пример #9
0
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'))
Пример #10
0
def health_coro(args):
    c = EsClient(host=args.host, port=args.port)
    s = yield gen.Task(c.cluster_health)
    print(s.body.rstrip('\n'))
Пример #11
0
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'))
Пример #12
0
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'))