put localhost:9200/sunlight?pretty
{"settings":{"number_of_shards":3,"number_of_replicas":2},"mappings":{"properties":{"commodity_id":{"type":"long"},"commodity_name":{"type":"text"},"picture_url":{"type":"keyword"},"price":{"type":"double"}}}}
修改索引的副本数量
PUT localhost:9200/sunlight/_settings
{"number_of_replicas":3}
查看索引
get localhost:9200/sunlight
{"sunlight":{"aliases":{},"mappings":{"properties":{"commodity_id":{"type":"long"},"commodity_name":{"type":"text"},"picture_url":{"type":"keyword"},"price":{"type":"double"}}},"settings":{"index":{"routing":{"allocation":{"include":{"_tier_preference":"data_content"}}},"number_of_shards":"3","provided_name":"sunlight","creation_date":"1637129366674","number_of_replicas":"3","uuid":"ZjyWoA7mQyeXZKVvuyPIrQ","version":{"created":"7130299"}}}}}
创建索引
创建索引并且不指定类型,以及映射类型
PUT http://127.0.0.1:9200/sunlight
这样创建的知识单纯创建索引,没有映射字段
获取索引的映射数据(字段类型)
get localhost:9200/sunlight/_mapping
{"hundsun":{"mappings":{"properties":{"commodity_id":{"type":"long"},"commodity_name":{"type":"text"},"picture_url":{"type":"keyword"},"price":{"type":"double"}}}}}
索引添加别名
put localhost:9200/hundsun/_alias/sunlight
{"acknowledged":true}