因兼容性问题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'