查看记录

查看单条记录,代码如下:

# encoding:utf-8
#!/usr/bin/python

from elasticsearch import Elasticsearch

class ElasticObj:
    def __init__(self, index_name, index_type, ip ="127.0.0.1"):

        '''
        :param index_name: 索引名称
        :param index_type: 索引类型
        '''
        self.index_name =index_name
        self.index_type = index_type

        # 无用户名密码状态
        self.es = Elasticsearch([ip])

        #用户名密码状态
        # self.es = Elasticsearch([ip],http_auth=('elastic', 'password'),port=9200)

    '''
    查看单条记录
    '''
    def Get_Data_By_Id(self, id):
        print  self.es.get(index=self.index_name, doc_type=self.index_type, id=id)

if __name__ == "__main__":

    obj =ElasticObj("test", "test_type", ip ="127.0.0.1")
    obj.Get_Data_By_Id(1)

执行结果:

{u'_type': u'test_type', u'_source': {u'url': u'https://www.codercto.com/courses/d/61.html', u'id': 1, u'title': u'Eloquent: \u5165\u95e8'}, u'_index': u'test', u'_version': 1, u'found': True, u'_id': u'1'}

点击查看所有 Python 操作 ElasticSearch 简明教程 文章: https://codercto.com/courses/l/6.html

查看所有标签

欲罢不能

欲罢不能

[美] 亚当·奥尔特 / 闾佳 / 机械工业出版社 / 2018-4-1 / 59.00元

全面揭秘和解决“行为上瘾”的奠基之作 美国亚马逊分类图书畅销榜第一名 行为上瘾是什么?诱人上瘾的体验是如何设计出来的? 如何远离行为上瘾?如何用行为上瘾做些好事? ◆ 内容简介 ◆ 欢迎来到“行为上瘾”的时代! 我们中近半数人至少有一种“行为上瘾”:无时无刻盯着手机,不断刷朋友圈,通宵追看电视剧集,没日没夜打游戏,频繁查看邮件,用太多时间工作…… 而那些生......一起来看看 《欲罢不能》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具