python orm elasticsearch_Python elasticsearch5包_程序模块 - PyPI - Python中文网

本文介绍了Python中的Elasticsearch低级客户端elasticsearch5,它是与Elasticsearch5.x兼容的基础库,提供与Elasticsearch交互的功能,如创建索引、序列化数据类型。此外,还提到了elasticsearch-dsl作为更高级别的客户端,提供DSL查询和持久化层。示例展示了如何创建索引、插入文档并获取数据。文章最后提及了许可证和社区资源。
摘要由CSDN通过智能技术生成

ElasticSearch的官方低级客户端。它的目标是提供

python中所有与elasticsearch相关的代码的基础;因此它尝试

没有意见,而且很容易扩展。

对于范围更为有限的更高级别客户端库,请查看

elasticsearch-dsl-位于

elasticsearch-py。

它提供了一种更方便、更惯用的方式来编写和操作

queries。它与elasticsearch的json dsl很接近,反映了它的

术语和结构,同时公开来自python的dsl的整个范围

直接使用定义的类或类查询集表达式。

它还提供了一个可选的persistence layer用于将文档作为

类似于orm的python对象:定义映射、检索和保存

文档,将文档数据包装到用户定义的类中。

兼容性

库与elasticsearch5.x兼容。弹性搜索2.x

请使用elasticsearch2,对于将来的版本,请使用elasticsearcch。

安装

使用pip:安装elasticsearch5包

pip install elasticsearch5

示例使用

简单用例:>>> from datetime import datetime

>>> from elasticsearch import Elasticsearch

# by default we connect to localhost:9200

>>> es = Elasticsearch()

# create an index in elasticsearch, ignore status code 400 (index already exists)

>>> es.indices.create(index='my-index', ignore=400)

{u'acknowledged': True}

# datetimes will be serialized

>>> es.index(index="my-index", doc_type="test-type", id=42, body={"any": "data", "timestamp": datetime.now()})

{u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type', u'_version': 1, u'ok': True}

# but not deserialized

>>> es.get(index="my-index", doc_type="test-type", id=42)['_source']

{u'any': u'data', u'timestamp': u'2013-05-12T19:45:31.804229'}

功能

客户的功能包括:translating basic Python data types to and from json (datetimes are not

decoded for performance reasons)

configurable automatic discovery of cluster nodes

persistent connections

load balancing (with pluggable selection strategy) across all available nodes

failed connection penalization (time based - failed connections won’t be

retried until a timeout is reached)

support for ssl and http authentication

thread safety

pluggable architecture

许可证

2017 ElasticSearch版权所有

根据apache许可证2.0版(以下简称“许可证”)授权;

除非符合许可证,否则您不能使用此文件。

您可以在

除非适用法律要求或书面同意,否则软件

根据许可证分发是按“原样”分发的,

没有任何保证或条件,无论是明示或暗示。

查看管理权限的特定语言的许可证

许可下的限制。

生成状态

欢迎加入QQ群-->: 979659372

推荐PyPI第三方库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值