SHARE
TWEET

escrita.py

correiabrux Jan 25th, 2019 (edited) 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ apt install python-pip
  2. $ pip install elasticsearch
  3. $ python
  4.  
  5. from datetime import datetime
  6. from elasticsearch import Elasticsearch
  7. es = Elasticsearch(['http://127.0.0.1:9200'])
  8.  
  9. doc = {
  10.     'author': 'kimchy',
  11.     'text': 'Elasticsearch: cool. bonsai cool.',
  12.     'timestamp': datetime.now(),
  13. }
  14. res = es.index(index="test-index", doc_type='tweet', id=1, body=doc)
  15. print(res['result'])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top