Package: elasticsearch_tornado
Tornado Elasticsearch ClientTornado HTTP client for Elasticsearch. Its goal is to provide common
ground for all Elasticsearch-related code in tornado and provide a
similar api to the official elasticsearch python client (elasticsearch-py).
However, this client only works for HTTP (no thrift or memcache) and doesn’t
support connection pooling at this time (one client per instance). This
allows for you to design your own pooling/handling of callbacks.Elasticsearch CompatibilityThe library is compatible with Elasticsearch 2.XInstallationpipinstallelasticsearch_tornadoDocumentationhttp://elasticsearch-tornado.readthedocs.org/en/latest/CLIElasticsearch Tornado also provides a handy cli for interacting with
Elasticsearch clusters. Here are a few handy commands:# indexing$catdata.json{"index":{"_index":"test","_type":"type1","_id":"1"}}{"user":"foo","age":100}{"index":{"_index":"test","_type":"type1","_id":"2"}}{"user":"bar","age":99}$catdata.json|etindex{"took":19,"errors":false,"items":[{"index":{"_index":"test","_type":"type1","_id":"1","_version":8,"_shards":{"total":2,"successful":1,"failed":0},"status":200}}]}# searching$etsearch-q'age:99'{"took":5,"timed_out":false,"_shards":{"total":8,"successful":8,"failed":0},"hits":{"total":2,"max_score":1.5108256,"hits":[{"_index":"test","_type":"type1","_id":"2","_score":1.5108256},{"_index":"test","_type":"test_type","_id":"2","_score":1.5108256,"_source":{"user":"bar","age":99}}]}}# cat API$etcatmaster127.0.0.1127.0.0.18200.05d*RandallShire$etcatnodes127.0.0.1127.0.0.18200.05d*RandallShire$etcatshardsindex2pSTARTED0131b127.0.0.1RandallShireindex2rUNASSIGNEDindex4pSTARTED13.7kb127.0.0.1RandallShireindex4rUNASSIGNEDindex3pSTARTED0131b127.0.0.1RandallShireindex3rUNASSIGNEDindex1pSTARTED0131b127.0.0.1RandallShireindex1rUNASSIGNEDindex0pSTARTED0131b127.0.0.1RandallShireindex0rUNASSIGNEDtest0pSTARTED0159b127.0.0.1RandallShiretest0rUNASSIGNED.scripts0pSTARTED12.7kb127.0.0.1RandallShireExample useSimple use-case:from__future__importprint_functionfromelasticsearch_tornadoimportEsClient,serializefromfunctoolsimportpartialfromtornadoimportioloop,genimportjsonc=EsClient()@gen.coroutinedefindex(doc):p=partial(c.index_doc,'test_index','test_doctype',serialize(doc),)res=yieldgen.Task(p)raisegen.Return(res)@gen.coroutinedefget(doc_id):p=partial(c.get_doc,'test_index',doc_id,)res=yieldgen.Task(p)raisegen.Return(res)@gen.coroutinedefmain_coro():res=yieldindex({"user":"foo","age":100})doc_id=json.loads(res.body).get('_id','')res=yieldget(doc_id)print(res.body)ioloop.IOLoop.instance().run_sync(main_coro){"_index":"test_index","_type":"test_doctype","_id":"AVQmGdzo66UC-UgKXqlX","_version":1,"found":true,"_source":{"age":100,"user":"foo"}}Python CompatibilityTested with python:
2.6, 2.7, 3.2, 3.3, 3.4, 3.5 and pypyLicenseCopyright 2014-2016 Daniel HodgesLicensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.RequirementsBuild status