最新版本库设计

因兼容性问题type=string,index=not_analyzed会变成type=keyword

反之则type=text

curl -XPUT 192.168.1.101:9200/wp?pretty -d '
 {
     "settings" : {
         "index" : {
             "number_of_shards" : 1,
             "number_of_replicas" : 0
         }
     },
     "mappings" : {
         "wp" : {
             "properties" : {
                 "id" : {
                     "type" : "string",
                     "index" : "not_analyzed"
                 },
                 "data" : {
                     "type" : "text",
                     "index" : "not_analyzed"
                 }
             }
         }
     }
 }'

curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
     "commands" : [
         {
           "allocate_empty_primary" : {
                 "index" : "wp", "shard" : 0,
                 "node" : "node-main"
           }
         }
     ]
 }
 '

curl -XPUT 127.0.0.1:9200/category?pretty -d '
 {
     "settings" : {
         "index" : {
             "number_of_shards" : 1,
             "number_of_replicas" : 0
         }
     },
     "mappings" : {
         "category" : {
             "properties" : {
                 "original_id" : {
                     "type" : "string",
                     "index" : "not_analyzed"
                 },
                 "lib_code" : {
                     "type" : "string",
                     "index" : "not_analyzed"
                 },
                 "year" : {
                     "type" : "long"
                 },
                 "source" : {
                     "type" : "string",
                     "index" : "not_analyzed"
                 }
             }
         }
     }
 }'

curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
     "commands" : [
         {
           "allocate_empty_primary" : {
                 "index" : "category", "shard" : 0,
                 "node" : "node-main"
           }
         }
     ]
 }
 '

curl -XPUT 127.0.0.1:9200/fragment?pretty -d '
{
    "settings" : {
        "index" : {
            "number_of_shards" : 16,
            "number_of_replicas" : 0
        },
        "analysis": {
              "analyzer": {
                   "comma": {
                      "tokenizer": "comma_tokenizer"
                }
              },
              "tokenizer": {
                  "comma_tokenizer": {
                       "type": "pattern",
                    "pattern": ","
                   }
              }
        }
    },
    "mappings" : {
        "fragment" : {
            "properties" : {
                "lib_code" : {
                    "type" : "string",
                    "index" : "not_analyzed"
                },
                "author" : {
                    "type": "text",
                    "analyzer": "comma",
                    "search_analyzer": "comma"
                },
                "year" : {
                    "type" : "long"
                },
                "text" : {
                    "type" : "string",
                    "index" : "analyzed",
                    "analyzer": "ik_smart",
                    "search_analyzer": "ik_max_word"
                }
            }
        }
    }
}'

curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
     "commands" : [
         {
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 0,
                 "node" : "node-101-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 1,
                 "node" : "node-102-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 2,
                 "node" : "node-103-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 3,
                 "node" : "node-104-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 4,
                 "node" : "node-105-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 5,
                 "node" : "node-106-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 6,
                 "node" : "node-107-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 7,
                 "node" : "node-108-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 8,
                 "node" : "node-109-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 9,
                 "node" : "node-110-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 10,
                 "node" : "node-111-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 11,
                 "node" : "node-112-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 12,
                 "node" : "node-113-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 13,
                 "node" : "node-114-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 14,
                 "node" : "node-115-0"
           }
         },{
           "allocate_empty_primary" : {
                 "index" : "fragment", "shard" : 15,
                 "node" : "node-116-0"
           }
         }
     ]
 }'

curl -XPOST 'localhost:9200/fragment/_close'

curl -XPUT 'localhost:9200/fragment/_settings?pretty' -H 'Content-Type: application/json' -d'
{
    "index.store.preload": ["*"]
}
'

curl -XPOST 'localhost:9200/fragment/_open'  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值