Elasticsearch 是优秀的文档数据库,在咱们使用集群方式建立咱们的文档数据时,须要根据集群node数量合理设置分片个数 从而提升数据查询、读取 效率;node
下面是分片设置块数据库
"settings": { "number_of_shards": 12,#分片个数,在建立索引不指定时 默认为 5; "number_of_replicas": 1 #数据副本,通常设置为1; },
下面是一个建立索引并设置分片的例子:json
curl -X PUT \ http://$1:9200/your_index_name/ \ -H 'content-type: application/json' \ -d '{ "settings": { "number_of_shards": 12, "number_of_replicas": 1 }, "mappings": { "sms_up": { "dynamic_templates": [ { "strings_as_keywords": { "match_mapping_type": "string", "mapping": { "type": "keyword" } } } ], "properties": { "account_id": { "type": "long" }, "date": { "type": "date", "format": "yyyy-MM-dd" }, "is_push_sms_up": { "type": "short" }, "mobile": { "type": "keyword" }, "push_sms_up_time": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }, "request_id": { "type": "keyword" }, "request_time": { "type": "date", "format": "epoch_second" }, "sms_account_primary": { "type": "integer" }, "sms_content": { "type": "keyword" }, "sms_exno": { "type": "keyword" }, "sms_facilitator_id": { "type": "integer" }, "sms_msgid": { "type": "keyword" }, "sms_sign_id": { "type": "integer" }, "sms_spno": { "type": "keyword" }, "sms_type": { "type": "long" }, "sms_up_rtime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" } } } } }'