This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Thin Python client for Elasticsearch

This is a little wrapper over the requests module that helps you do your thing with Elasticsearch. But not too much. For each request, you need to specify the following, where they are applicable:

  • desired request method
  • index, type, ID
  • “suffix” (which might be the _search, _bulk, etc at the end of the URL)
  • a dictionary or a string with the data you want to submit

Why would I want that?

Two reasons:

  • flexibility - the point of this client is to keep up with the many features constantly added to Elasticsearch. You can customize your index operations and queries as much as you need
  • documentation - once you get the hang of the few options particular to this client, you only have to look at the documentation on Elasticsearch itself to access its features

If this is not what you want, I would suggest to look at pyes or pyelasticsearch

Features and usage

There are a few files in there at the moment:

  • slimes.py - the module itself
  • tests_slimes.py - unit tests

Here are the main features:

Converts your dict to JSON (you can disable that for stuff like bulks)

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200"])
#define the document
testdoc = {"foo": 2345, "bar": True}
#post the document
my_requester.request(method="post",
    myindex="testindex",
    mytype="testtype",
    mydata=testdoc)

Can get a list of nodes, for redundancy

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200","my_other_server:9200"])

Loads the JSON results for you

If something goes wrong (eg: non 2XX status code), you’ll get an exception. Otherwise, you’ll get a dictionary with the results from ES:

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200"])
myquery = {\
    "query": {\
            "term": {\
                    "age": 28\
            }\
    }\
}
results = my_requester.request(method="post",
    myindex="testindex",
    mytype="testtype",
    mysuffix="_search",
    mydata=myquery)
print "Number of hits is %d" % result['hits']['total']

Can receive parameters at will

So you can index with the “create” parameter, like this:

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200"])
testdoc={"foo": "bar"}
my_requester.request(method="put",
    myindex="testindex",
    mytype="testtype",
    myID=1,
    mysuffix="?op_type=create",
    mydata=testdoc)

Or, you can put the parameter(s) as a dictionary:

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200"])
testdoc={"foo": "bar"}
my_requester.request(method="put",
    myindex="testindex",
    mytype="testtype",
    myID=1,
    myparams={"op_type":"create"},
    mydata=testdoc)

And you can also specify a timeout:

#!/usr/bin/env python
import slimes
my_requester = slimes.Requester(["localhost:9200"])
#give it 10 seconds to complete, otherwise give Exception
my_requester.request(mytimeout=10)

TODOes

Enhancements will be about the transport. Stuff like: - use thrift - get all cluster nodes

Stay tuned :)

Bugs

Please feel free to report them on github

Release History

Release History

0.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
SlimES-0.0.2.tar.gz (4.2 kB) Copy SHA256 Checksum SHA256 Source Sep 10, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting