ElasticSearch学习笔记-Python API使用

本文档记录了ElasticSearch的学习笔记,重点介绍了如何使用Python API进行操作。内容包括参考资料和代码实例,帮助读者理解如何借助Python与ElasticSearch进行交互。
摘要由CSDN通过智能技术生成

ElasticSearch学习笔记-Python API使用

1. 参考资料

  1. Elasticsearch 开发指南
  2. Elasticsearch 官网
  3. CSDN文章
  4. ElasticSearch博客园
  5. Python操作ElasticSearch
  6. 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])
        # 用户名密码状态
        # self.es = Elasticsearch([ip], http_auth=('elastic', 'password'), port=9200)

    def create_index(self):
        """
        Create an i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值