Skip to content

Instantly share code, notes, and snippets.

@skade
Created March 14, 2018 07:31
Show Gist options
  • Save skade/1d97439807233b018e91f2b4ea0cc1d2 to your computer and use it in GitHub Desktop.
Save skade/1d97439807233b018e91f2b4ea0cc1d2 to your computer and use it in GitHub Desktop.
import http.client
import json
conn = http.client.HTTPConnection("localhost:9200")
conn.request("GET", "/my_index/_search?size=10000")
r1 = conn.getresponse()
result = json.loads(r1.read().decode('utf-8'))
for hit in result["hits"]["hits"]:
print(json.dumps({ "index" : { "_type": hit["_type"], "_id" : hit["_id"] }}))
print(json.dumps(hit["_source"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment