elasticsearch-index-management

栏目: 后端 · 发布时间: 5年前

内容简介:如果你想禁止自动创建索引,你可以通过在 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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

神经网络与机器学习(原书第3版)

神经网络与机器学习(原书第3版)

[加] Simon Haykin / 申富饶、徐烨、郑俊、晁静 / 机械工业出版社 / 2011-3 / 79.00元

神经网络是计算智能和机器学习的重要分支,在诸多领域都取得了很大的成功。在众多神经网络著作中,影响最为广泛的是Simon Haykin的《神经网络原理》(第3版更名为《神经网络与机器学习》)。在本书中,作者结合近年来神经网络和机器学习的最新进展,从理论和实际应用出发,全面、系统地介绍了神经网络的基本模型、方法和技术,并将神经网络和机器学习有机地结合在一起。 本书不但注重对数学分析方法和理论的探......一起来看看 《神经网络与机器学习(原书第3版)》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具