PUT /order { "settings": { "number_of_shards": 3, "number_of_replicas": 2 }, "mappings": { "carpoolType":{ "properties": { "orderNo":{ "type": "string", "index": "not_analyzed" } } } } } #! Deprecation: The [string] field is deprecated, please use [text] or [keyword] instead on [orderNo] { "acknowledged": true, "shards_acknowledged": true } ES5.0版本中string类型被拆分为text和keyword类型: https://www.elastic.co/blog/strings-are-dead-long-live-strings
2. 修改索引
1 2 3 4
PUT /order/_settings { "number_of_replicas": 2 }
更新分词器
1 2 3 4 5 6 7 8 9 10 11 12 13 14
POST /order/_close PUT /order/_settings { "analysis": { "analyzer": { "content":{ "type":"customer", "tokenizer":"whitespace" } } } } POST /order/_open 添加分析器之前必须先关闭索引,添加之后再打开索引。
尝试修改索引主分片数:
1 2 3 4
PUT /order/_settings { "number_of_shards": 2 }
错误提示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "Can't update non dynamic settings [[index.number_of_shards]] for open indices [[order/2cOJ6Ga7THCyW10idoPPig]]" } ], "type": "illegal_argument_exception", "reason": "Can't update non dynamic settings [[index.number_of_shards]] for open indices [[order/2cOJ6Ga7THCyW10idoPPig]]" }, "status": 400 }
POST /order/_close POST /order/_open health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open .kibana 8n5wnGEjRJ-aVa54l_jTjA 1 1 1 0 3.1kb 3.1kb yellow open order uSh9K26CS_q1uZKaos7NRQ 3 2 0 0 486b 486b