内容简介:如果你想禁止自动创建索引,你可以通过在 config/elasticsearch.yml 的每个节点下添加下面的配置:2.0版本
如果你想禁止自动创建索引,你可以通过在 config/elasticsearch.yml 的每个节点下添加下面的配置:
2.0版本
action.auto_create_index: false
创建索引
curl -X PUT "localhost:9200/dev_employee_20181221"
WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X PUT "localhost:9200/dev_employee_20181219" {"acknowledged":true,"shards_acknowledged":true,"index":"dev_employee_20181219"}
删除索引
// 删除一个
curl -X DELETE "localhost:9200/dev_employee_20181221"
// 删除多个
curl -X DELETE "localhost:9200/dev_employee_20181220,dev_employee_20181221"
curl -X DELETE "localhost:9200/dev_employee_*"
// 删除所有
curl -X DELETE "localhost:9200/_all"
curl -X DELETE "localhost:9200/*"
WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X DELETE "localhost:9200/dev_employee_20181219" {"acknowledged":true}
索引设置
number_of_shards
每个索引的主分片数,默认值是 5 。这个配置在索引创建后不能修改。
number_of_replicas
每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改。
curl -X PUT "localhost:9200/my_temp_index" -H 'Content-Type: application/json' -d' { "settings": { "number_of_shards" : 1, "number_of_replicas" : 0 } } '
curl -X PUT "localhost:9200/my_temp_index/_settings" -H 'Content-Type: application/json' -d' { "number_of_replicas": 1 } '
配置分词器
curl -X PUT "localhost:9200/spanish_docs" -H 'Content-Type: application/json' -d' { "settings": { "analysis": { "analyzer": { "es_std": { "type": "standard", "stopwords": "_spanish_" } } } } } '
curl -X GET "localhost:9200/spanish_docs/_analyze?analyzer=es_std" -H 'Content-Type: application/json' -d' El veloz zorro marrón '
// 创建索引
curl -X PUT "localhost:9200/dev_employee_20181221"
// 给别名添加索引
curl -X PUT "localhost:9200/dev_employee_20181221/_alias/dev_employee"
// 检测这个别名指向哪些索引 同一别名多个索引
curl -X GET "localhost:9200/*/_alias/dev_employee"
// 哪些别名指向这个索引 一个索引多个别名
curl -X GET "localhost:9200/dev_employee_20181221/_alias/*"
// 切别名
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d' { "actions": [ { "remove": { "index": "dev_employee_20181220", "alias": "dev_employee" }}, { "add": { "index": "dev_employee_20181221", "alias": "dev_employee" }} ] } '
WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X PUT "localhost:9200/dev_employee_20181221" {"acknowledged":true,"shards_acknowledged":true,"index":"dev_employee_20181221"} WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X PUT "localhost:9200/dev_employee_20181221/_alias/dev_employee" {"acknowledged":true} WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X GET "localhost:9200/*/_alias/dev_employee" {"dev_employee_20181221":{"aliases":{"dev_employee":{}}},"dev_employee_20181220":{"aliases":{"dev_employee":{}}}} WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X GET "localhost:9200/dev_employee_20181221/_alias/*" {"dev_employee_20181221":{"aliases":{"dev_employee":{},"sit_employee":{}}}} WKQ@WKQ-PC MINGW64 /d/WorkSpaces $ curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d' { "actions": [ { "remove": { "index": "dev_employee_20181220", "alias": "dev_employee" }}, { "add": { "index": "dev_employee_20181221", "alias": "dev_employee" }} ] } ' {"acknowledged":true}
以上所述就是小编给大家介绍的《elasticsearch-index-management》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。