我正在努力让pyes工作并制作一个从文档
派生的最小例子from pyes import ES
conn = ES('127.0.0.1:9200', timeout=30, retry_time=60, max_retries=10)
mapping = {
"properties": {
'name': {"type" : "text"}
}
}
try:
conn.indices.delete_index("test-index")
except:
pass
conn.indices.create_index("test-index")
conn.indices.put_mapping("test-type", mapping, ["test-index"])
我比阅读一些数据并刷新索引
conn.index({"name":"Joe Tester"}, "test-index", "test-type", 1)
conn.index({"name":"Bill Baloney"}, "test-index", "test-type", 2)
conn.indices.refresh()
但是,这会导致错误
pyes.exceptions.ElasticSearchException: Unknown exception type: 408, {u'status': u'yellow', u'number_of_nodes': 1, u'unassigned_shards': 10, u'number_of_pending_tasks': 0, u'number_of_in_flight_fetch': 0, u'timed_out': True, u'active_primary_shards': 19, u'task_max_waiting_in_queue_millis': 0, u'cluster_name': u'elasticsearch', u'relocating_shards': 0, u'active_shards_percent_as_number': 65.51724137931035, u'active_shards': 19, u'initializing_shards': 0, u'number_of_data_nodes': 1, u'delayed_unassigned_shards': 0}
我谷歌错误,但找不到任何东西?这是我的python版本和pyes版本
>>> import sys
>>> print (sys.version)
2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
$ pip freeze | grep pyes
pyes==0.99.6
以下是我的elasticsearch服务器日志的输出
$ ./elasticsearch
[2017-08-29T21:48:00,720][INFO ][o.e.n.Node ] [] initializing ...
[2017-08-29T21:48:00,838][INFO ][o.e.e.NodeEnvironment ] [Qk5rOst] using
[1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [108.7gb], net total_space [464.7gb], spins? [unknown], types [hfs]
[2017-08-29T21:48:00,838][INFO ][o.e.e.NodeEnvironment ] [Qk5rOst] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-08-29T21:48:00,840][INFO ][o.e.n.Node ] node name
[Qk5rOst] derived from node ID [Qk5rOstSSrSVW-jkzaGQCw]; set [node.name] to override
[2017-08-29T21:48:00,840][INFO ][o.e.n.Node ] version[5.5.2], pid[14107], build[b2f0c09/2017-08-14T12:33:14.154Z], OS[Mac OS X/10.10.5/x86_64],
JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_92/25.92-b14]
[2017-08-29T21:48:00,841][INFO ][o.e.n.Node ] JVM arguments [-
Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -
Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -
Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -
Dio.netty.noKeySetOptimization=true, -
Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -
Des.path.home=/Users/xflorian/Downloads/elasticsearch-5.5.2]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [aggs-matrix-stats]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [ingest-common]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [lang-expression]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [lang-groovy]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [lang-mustache]
[2017-08-29T21:48:02,525][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [lang-painless]
[2017-08-29T21:48:02,526][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [parent-join]
[2017-08-29T21:48:02,526][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [percolator]
[2017-08-29T21:48:02,526][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [reindex]
[2017-08-29T21:48:02,526][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [transport-netty3]
[2017-08-29T21:48:02,526][INFO ][o.e.p.PluginsService ] [Qk5rOst] loaded
module [transport-netty4]
[2017-08-29T21:48:02,527][INFO ][o.e.p.PluginsService ] [Qk5rOst] no
plugins loaded
[2017-08-29T21:48:04,849][INFO ][o.e.d.DiscoveryModule ] [Qk5rOst] using
discovery type [zen]
[2017-08-29T21:48:05,490][INFO ][o.e.n.Node ] initialized
[2017-08-29T21:48:05,490][INFO ][o.e.n.Node ] [Qk5rOst] starting
...
[2017-08-29T21:48:05,829][INFO ][o.e.t.TransportService ] [Qk5rOst]
publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}
[2017-08-29T21:48:08,904][INFO ][o.e.c.s.ClusterService ] [Qk5rOst] new_master {Qk5rOst}{Qk5rOstSSrSVW-jkzaGQCw}{eQgZtDCGREOVN-v-9IKBtw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-08-29T21:48:08,933][INFO ][o.e.h.n.Netty4HttpServerTransport] [Qk5rOst] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}
[2017-08-29T21:48:08,933][INFO ][o.e.n.Node ] [Qk5rOst] started
[2017-08-29T21:48:08,951][INFO ][o.e.g.GatewayService ] [Qk5rOst] recovered [0] indices into cluster_state
[2017-08-29T21:48:17,849][INFO ][o.e.c.m.MetaDataCreateIndexService] [Qk5rOst]
[test-index] creating index, cause [api], templates [], shards [5]/[1], mappings []
[2017-08-29T21:48:18,168][INFO ][o.e.c.m.MetaDataMappingService] [Qk5rOst]
[test-index/FFRQYrw0TyiVpI6RbwkPYQ] create_mapping [test-type]
[2017-08-29T21:48:21,095][INFO ][o.e.c.m.MetaDataDeleteIndexService] [Qk5rOst]
[test-index/FFRQYrw0TyiVpI6RbwkPYQ] deleting index
[2017-08-29T21:48:21,163][INFO ][o.e.c.m.MetaDataCreateIndexService] [Qk5rOst]
[test-index] creating index, cause [api], templates [], shards [5]/[1], mappings []
[2017-08-29T21:48:21,261][INFO ][o.e.c.m.MetaDataMappingService] [Qk5rOst]
[test-index/5TZAKLU-T-2Jv2sz-6M0eQ] create_mapping [test-type]
[2017-08-29T21:49:12,572][INFO ][o.e.c.m.MetaDataDeleteIndexService] [Qk5rOst]
[test-index/5TZAKLU-T-2Jv2sz-6M0eQ] deleting index
[2017-08-29T21:49:12,632][INFO ][o.e.c.m.MetaDataCreateIndexService] [Qk5rOst]
[test-index] creating index, cause [api], templates [], shards [5]/[1], mappings []
[2017-08-29T21:49:12,723][INFO ][o.e.c.m.MetaDataMappingService] [Qk5rOst] [test-index/YgPlhKEtQ8OSFyCgaL0Bcg] create_mapping [test-type]