Gulir Elasticsearch dengan paralelisme r

from elasticsearch import Elasticsearch

# Init elasticsearch client
es = Elasticsearch()

INDEX = "index"
DOC_TYPE = "doc_type"

# get numver of shards
shards_info = es.search_shards(INDEX, DOC_TYPE)
number_of_shards = len(shards_info['shards'])

# Shard number to routing key
shards = {}
routing = 0

while len(shards.keys()) < number_of_shards:
    result = client.search_shards(index, doc_type, routing=i)
    shard_number = result['shards'][0][0]['shard']
    if shard_number not in shards:
        shards[shard_number] = i
    i += 1

print(shards)
Busy Bison