correiabrux

escrita.py

Jan 25th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  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'])
Advertisement
Add Comment
Please, Sign In to add comment