There are libraries to do these pyes and pyelasticsearch. The pyelasticsearch website looks good, and pyes takes a different approach, but also good.
On the other hand, this code works, and it is very simple.
import urllib2 as urllib import json import pprint query = { "from":0, "size":10, "query":{ "field" : { "name" : "david" } }, "sort":[ {"name":"asc"}, {"lastName":"asc"} ] } query = json.dumps(query) response = urllib.urlopen( 'http://localhost:9200/users/users/_search', query ) result = json.loads( response.read() ) pprint.pprint(result)
So, I am thinking of using simple code instead of learning library tricks.
Delta
source share