ElasticSearch学习笔记-Python API使用
1. 参考资料
- Elasticsearch 开发指南
- Elasticsearch 官网
- 优快云文章
- ElasticSearch博客园
- Python操作ElasticSearch
- ElasticSearch Python API官网
2. 代码实例
通过Python简单操作ElasticSearch
# -.- coding:utf-8 -.-
import json
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
class ElasticObj:
def __init__(self, index_name, index_type, index_conf, ip="127.0.0.1"):
"""
ElasticObj initialize
:param index_name: 索引名称
:param index_type: 索引类型
"""
self.index_name = index_name
self.index_type = index_type
self.index_conf = index_conf
# 无用户名密码状态
self.es = Elasticsearch(hosts=[ip])