@@ -164,13 +164,13 @@ def schema_mapping(name, schema):
164164 }
165165
166166
167- def index_settings ():
167+ def index_settings (primary_shards = 3 , replicate_shards = 1 ):
168168 return {
169169 'settings' : {
170170 'index.max_result_window' : 99999 ,
171171 'index.mapping.total_fields.limit' : 5000 ,
172- 'index.number_of_shards' : 1 ,
173- 'index.number_of_replicas' : 0 ,
172+ 'index.number_of_shards' : primary_shards ,
173+ 'index.number_of_replicas' : replicate_shards ,
174174 'index.max_ngram_diff' : 32 ,
175175 'analysis' : {
176176 'filter' : {
@@ -484,6 +484,8 @@ def create_snovault_index_alias(es, indices):
484484def run (app , collections = None , dry_run = False ):
485485 index = app .registry .settings ['snovault.elasticsearch.index' ]
486486 registry = app .registry
487+ primary_shards = registry .settings .get ('elasticsearch.shards.primary' , 3 )
488+ replicate_shards = registry .settings .get ('elasticsearch.shards.replicate' , 1 )
487489 if not dry_run :
488490 es = app .registry [ELASTIC_SEARCH ]
489491 print ('CREATE MAPPING RUNNING' )
@@ -503,9 +505,9 @@ def run(app, collections=None, dry_run=False):
503505 if mapping is None :
504506 continue # Testing collections
505507 if dry_run :
506- print (json .dumps (sorted_dict ({index : {doc_type : mapping }}), indent = 4 ))
508+ print (json .dumps (sorted_dict ({index : {collection_name : mapping }}), indent = 4 ))
507509 continue
508- create_elasticsearch_index (es , index , index_settings ())
510+ create_elasticsearch_index (es , index , index_settings (primary_shards , replicate_shards ))
509511 set_index_mapping (es , index , mapping )
510512 if collection_name != 'meta' :
511513 indices .append (index )
0 commit comments