索引 = 数据库,没有自动创建

先连接,后操作,先安装包

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)
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐