Elasticsearch python API 文档Documentation 2.3.0 by Honza Král

官方文档来源:http://elasticsearch-py.rtfd.org/ 网站左侧提供PDF的下载
参考博客:(还是google靠谱,能搜出几篇相关文章来)
1. 2015-08-21 http://www.cnblogs.com/letong/p/4749234.html
2. http://rfyiamcool.blog.51cto.com/1030776/1420811
3. 2016-2-22 http://www.jianshu.com/users/2ea4b65c0f30/latest_articles

1. Compatibility

2. 安装与用法样例

安装见:http://blog.csdn.net/abnergong/article/details/50776947
用法样例:

from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
doc = {
'author': 'kimchy',
'text': 'Elasticsearch: cool. bonsai cool.',
'timestamp': datetime.now(),
}
res = es.index(index="test-index", doc_type='tweet', id=1, body=doc)
print(res['created'])
res = es.get(index="test-index", doc_type='tweet', id=1)
print(res['_source'])
es.indices.refresh(index="test-index")
res = es.search(index="test-index", body={"query": {"match_all": {}}})
print("Got %d Hits:" % res['hits']['total'])
for hit in res['hits']['hits']:
print("%(timestamp)s %(author)s: %(text)s" % hit["_source"])

其中使用前必须的代码是:

from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()

3. Features

4. Environment considerations

5. 内容(Contents)

5.1 API文档(API Documentation)

【注意】为了适应Python的生态系统(ecosystem),我们使用from_代替from,doc_type代替type作为变量名

5.1.1 全局选项(Global options)

5.1.2 Elasticsearch

class elasticsearch.Elasticsearch(hosts=None, transport_class=<classelasticsearch.transport.Transport’>, **kwargs)

Elasticsearch低级客户端提供从Python到ES REST端点(endpoint)的直接映射。这个实例(即指es = Elasticsearch())有属性cat, cluster, indices, nodes和snapshot分别提供到CatClient, ClusterClient, IndicesClient, NodesClient and SnapshotClient的实例的访问(即用es.cat表示CatClient的实例),这是更好的也是目前仅支持的访问那些Client的函数方法的途径。

5.1.3 Indices(索引)

下面的函数是类class elasticsearch.client.IndicesClient(client)的方法。函数func的调用方法为es.indices.func

5.1.4 Cluster(集群)

下面的函数是类class elasticsearch.client.ClusterClient(client)的方法。函数func的调用方法为es.cluster.func
get_settings(flat_settings=True, timeout=1)
health()
pending_tasks()
put_settings
reroute
state
stats

5.1.5 Nodes(节点)

下面的函数是类class elasticsearch.client.NodesClient(client)的方法。
方法名func的调用方法为es.nodes.func()
hot_threads
info
stats

5.1.5 Cat(节点)

下面的函数是类class elasticsearch.client.CatClient(client)的方法。
方法名func的调用方法为es.cat.func()
aliases
allocation
count
fielddata
health
help
indices
….
thread_pool

Snapshot

下面的函数是类class elasticsearch.client.SnapshotClient(client)的方法。
方法名func的调用方法为es.snapshot.func()

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值