Git Product home page Git Product logo

tornado-es's Introduction

Build Status

Tornado-es

A tornado-powered python library that provides asynchronous access to elasticsearch.

Install

Via pip:

pip install tornadoes

Usage

Indexing a dummy document:

$ 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:

# -*- 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 © Globo.com

tornado-es's People

Contributors

scorphus avatar luizgpsantos avatar heynemann avatar sergiojorge avatar sjhewitt avatar newgene avatar nsigustavo avatar blampe avatar ricobl avatar gustavoluz avatar kmike avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.