用于ElasticSearch的Python客户端

elasticsearch2的Python项目详细描述


ElasticSearch的官方低级客户端。它的目标是提供 python中所有与elasticsearch相关的代码的基础;因此它尝试 没有意见,而且很容易扩展。

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

它提供了一种更方便、更惯用的方式来编写和操作 queries。它与elasticsearch的json dsl很接近,反映了它的 术语和结构,同时公开来自python的dsl的整个范围 直接使用定义的类或类查询集表达式。

它还提供了一个可选的persistence layer用于将文档作为 类似于orm的python对象:定义映射、检索和保存 文档,将文档数据包装到用户定义的类中。

兼容性

库与自0.90.x以来的所有ElasticSearch版本兼容,但是 必须使用匹配的主版本

对于elasticsearch 2.0及更高版本,请使用 图书馆。

对于elasticsearch 1.0及更高版本,请使用 图书馆。

对于elasticsearch 0.90.x,请使用 图书馆。

setup.py中设置需求的推荐方法 requirements.txt是:

# Elasticsearch 2.x
elasticsearch>=2.0.0,<3.0.0

# Elasticsearch 1.x
elasticsearch>=1.0.0,<2.0.0

# Elasticsearch 0.90.x
elasticsearch<1.0.0

开发分别在master1.x分支上进行。

安装

使用pip:

安装elasticsearch
pip install elasticsearch

示例使用

简单用例:

>>> 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'}

Full documentation

功能

客户的功能包括:

  • 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

许可证

2015 ElasticSearch版权所有

根据apache许可证2.0版(以下简称“许可证”)授权; 除非符合许可证,否则您不能使用此文件。 您可以在

http://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则软件 根据许可证分发是按“原样”分发的, 无任何明示或默示的保证或条件。 有关管理权限的特定语言和 许可下的限制。

生成状态

https://secure.travis-ci.org/elastic/elasticsearch-py.png

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaPax考试:从非标准Maven存储库解析Karaf特性存储库(XML文件)   java Spring启动Bean创建异常   java中将ArrayList转换为数组的方法   Android Studio的java Unity插件。   java在CheckStyle中从方法计数中排除getter和setter   HibernateJava。sql。SQLSyntaxErrorException:表/视图“序列”不存在   与命令行程序Java vs C通信   java WebView膨胀异常   java在O(n)java8流中寻找两个列表的交集   java使用Gradle运行单元测试时,最大堆大小在哪里设置?   ssl加载java应用程序(CXF)内的jks文件   CI:Jenkins Git:Simple Java项目:希望在特定时间在脚本上发送消息   java根据位置更改数字   java按数值排序字符串数组   macos java版本“1.6.0_65”是否与java 6模棱两可?   Cassandra中的java时间戳