常用操作

Elastic Search 常用操作

  • 创建索引默认配置操作
  • Alias操作
  1. 创建索引
PUT jmeter-no-source-1
{
  "settings": {
    "index": {
      "number_of_shards": 5,
      "number_of_replicas": 1
    }
  },
  "mappings": {
    "_default_": {
      "_source": {
        "enabled": false
      },
      "dynamic_templates": [
        {
          "storeallfieds": {//所有的字段都存储
            "match": "*",
            "mapping": {
              "store": true
            }
          }
        }
      ] } } }
  1. 添加Alias
curl -XPOST 'http://localhost:9200/_aliases' -d ' { "actions" : [ { "add" : { "index" : "test1", "alias" : "alias1" } }, { "add" : { "index" : "test2", "alias" : "alias1" } } ] }'
  1. reroute
_cluster/reroute
{
    "commands" : [ 
        {
          "allocate" : {
              "index" : "indexName", "shard" : 1, "node" : "1X84tRUQRvGG9MZ3L7ffyA","allow_primary" : true
          }
        }
    ]
}

allow_primary 是显示指定可以分配主shard.但有可能导致数据丢失
allow_primary 参数为true,将会创建一个空的没有任何数据的主shard

你可能感兴趣的:(elasticsearch)