本文整理汇总了Python中pyelasticsearch.ElasticSearch.status方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticSearch.status方法的具体用法?Python ElasticSearch.status怎么用?Python ElasticSearch.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyelasticsearch.ElasticSearch
的用法示例。
在下文中一共展示了ElasticSearch.status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cluster_size_3
# 需要导入模块: from pyelasticsearch import ElasticSearch [as 别名]
# 或者: from pyelasticsearch.ElasticSearch import status [as 别名]
def test_cluster_size_3(self):
cluster = self._make_one(size=3)
cluster.start()
self.assertEqual(len(cluster), 3)
self.assertEqual(len(cluster.hosts), 3)
self.assertEqual(len(os.listdir(cluster.working_path)), 3)
self.assertEqual(len(cluster.urls), 3)
client = ElasticSearch(cluster.urls, max_retries=2)
self.assertEqual(client.health()['number_of_nodes'], 3)
# test if routing works and data is actually distributed across nodes
client.create_index('test_shards', settings={
'number_of_shards': 1,
'number_of_replicas': 2,
})
client.index('test_shards', 'spam', {'eggs': 'bacon'})
client.refresh('test_shards')
shard_info = client.status()['indices']['test_shards']['shards']['0']
nodes = set([s['routing']['node'] for s in shard_info])
self.assertTrue(len(nodes) > 1)
示例2: len
# 需要导入模块: from pyelasticsearch import ElasticSearch [as 别名]
# 或者: from pyelasticsearch.ElasticSearch import status [as 别名]
sys.exit(1)
elasticsearch = parser.get('default', 'elasticsearch').strip('"').strip("'")
input = len(sys.argv)
if input < 2:
usage()
sys.exit(1)
else:
qname = sys.argv[1]
from pyelasticsearch import ElasticSearch
es = ElasticSearch(elasticsearch)
try:
s = es.status('oplog')
except:
print "Creating index: oplog"
try:
s = es.create_index('oplog')
print "sleeping for 5 to ensure index exists"
time.sleep(5)
except:
print "ERROR: index creation failed!"
sys.exit()
print "Creating queue: %s" % qname
try:
es.put_mapping('oplog',qname,{"properties" : { "from" : {"type" : "string", "null_value" : "na"}, "sent" : {"type" : "string", "null_value" : "na"}, "submitted" : {"type" : "date"}, "subject" : {"type" : "string", "null_value" : "na"}, "message" : {"type" : "string", "null_value" : "na"} }})
print "Created queue with mapping:"
print es.get_mapping('oplog',qname)