SlimES

Thin Python connector for Elasticsearch
Download

SlimES Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Price:
  • FREE
  • Publisher Name:
  • Radu Gheorghe

SlimES Tags


SlimES Description

SlimES is a little Python 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 submitWhy 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 featuresIf this is not what you want, I would suggest to look at pyes or pyelasticsearchFeatures and usageThere are a few files in there at the moment:- slimes.py - the module itself- tests_slimes.py - unit testsHere are the main features:Converts your dict to JSON (you can disable that for stuff like bulks)#!/usr/bin/env pythonimport slimesmy_requester = slimes.Requester()#define the documenttestdoc = {"foo": 2345, "bar": True}#post the documentmy_requester.request(method="post", myindex="testindex", mytype="testtype", mydata=testdoc)Can get a list of nodes, for redundancy#!/usr/bin/env pythonimport slimesmy_requester = slimes.Requester()Loads the JSON results for youIf 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 pythonimport slimesmy_requester = slimes.Requester()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" % resultCan receive parameters as a suffixSo you can index with the "create" parameter, like this:#!/usr/bin/env pythonimport slimesmy_requester = slimes.Requester()testdoc={"foo": "bar"}my_requester.request(method="put", myindex="testindex", mytype="testtype", myID=1, mysuffix="?op_type=create", mydata=testdoc)Product's homepage


SlimES Related Software