Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ apt install python-pip
- $ pip install elasticsearch
- $ python
- from datetime import datetime
- from elasticsearch import Elasticsearch
- es = Elasticsearch(['http://127.0.0.1:9200'])
- doc = {
- 'author': 'kimchy',
- 'text': 'Elasticsearch: cool. bonsai cool.',
- 'timestamp': datetime.now(),
- }
- res = es.index(index="test-index", doc_type='tweet', id=1, body=doc)
- print(res['result'])
Advertisement
Add Comment
Please, Sign In to add comment