Advertisement
correiabrux

leitura.py

Jan 25th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. $ pip install elasticsearch
  2.  
  3. from elasticsearch import Elasticsearch
  4. es = Elasticsearch(['http://127.0.0.1:9200'])
  5.  
  6. res = es.search(index="test-index", body={"query": {"match_all": {}}})
  7. print("Got %d Hits:" % res['hits']['total'])
  8. for hit in res['hits']['hits']:
  9.     print("%(timestamp)s %(author)s: %(text)s" % hit["_source"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement