https://github.com/globocom/tornado-es
A tornado-powered python library that provides asynchronous access to elasticsearch
https://github.com/globocom/tornado-es
Last synced: 11 months ago
JSON representation
A tornado-powered python library that provides asynchronous access to elasticsearch
- Host: GitHub
- URL: https://github.com/globocom/tornado-es
- Owner: globocom
- License: mit
- Created: 2012-05-14T13:49:21.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T19:25:06.000Z (almost 8 years ago)
- Last Synced: 2025-06-30T00:06:37.786Z (about 1 year ago)
- Language: Python
- Size: 148 KB
- Stars: 95
- Watchers: 85
- Forks: 32
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://travis-ci.org/globocom/tornado-es)
Tornado-es
==========
A tornado-powered python library that provides asynchronous access to elasticsearch.
Install
=======
Via pip:
pip install tornadoes
Usage
=====
Indexing a dummy document:
```bash
$ curl -XPUT 'http://localhost:9200/index_test/typo_test/1' -d '{
"typo_test" : {
"name" : "scooby doo"
}
}'
```
Tornado program used to search the document previously indexed:
```python
# -*- coding: utf-8 -*-
import json
import tornado.ioloop
import tornado.web
from tornadoes import ESConnection
class SearchHandler(tornado.web.RequestHandler):
es_connection = ESConnection("localhost", 9200)
@tornado.web.asynchronous
def get(self, indice="index_test", tipo="typo_test"):
query = {"query": {"match_all": {}}}
self.es_connection.search(callback=self.callback,
index=indice,
type=tipo,
source=query)
def callback(self, response):
self.content_type = 'application/json'
self.write(json.loads(response.body))
self.finish()
application = tornado.web.Application([
(r"/", SearchHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
```
Development
===========
Setup your development environment:
make setup
> *Note: Don't forget to create a virtualenv first*
Run tests:
make test
> *Note: Make sure ElasticSearch is running on port 9200*
Contributing
============
Fork, patch, test, and send a pull request.
License
=======
[MIT](http://opensource.org/licenses/MIT) © [Globo.com](https://github.com/globocom)