python操作elasticsearch(插入数据)
索引 = 数据库,没有自动创建先连接,后操作,先安装包pip install elasticsearch#!/usr/bin/pythonimport datetimefrom elasticsearch import Elasticsearches = Elasticsearch([{"host": "x.x.x.x", "port": 9200}])body = {'local_ip': 'x
·
索引 = 数据库,没有自动创建
先连接,后操作,先安装包
pip install elasticsearch
#!/usr/bin/python
import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch([{"host": "x.x.x.x", "port": 9200}])
body = {
'local_ip': 'x.x.x.x',
'queue_id': 'CC1681446071',
'recipient': 'fuck@ooxx.com',
'arrive_time': datetime.datetime(2018, 5, 12, 23, 57, 59),
'relay_domain': 'none',
'failed_reason': 'Host or domain name not found. Name service error for name=ooxx.com type=MX: Host not found, try again'
}
es.index(index='test_log', body=body)
更多推荐



所有评论(0)