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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

SQL完全手册

SQL完全手册

格罗夫 / 电子工业 / 2006-6 / 68.00元

本书为专业和非专业用户、程序员、数据处理方面的专业人士和希望理解sQL在今天计算机产业中的影响的经理们提供了关于SQL语言的全面深入的介绍。本书为理解和使用SQL提供了一个概念上的框架,描述了SQL的历史和SQL的标准,解释了SQL在各种计算机产业领域(如企业级数据处理、数据仓库、Web站点体系结构)中的作用。这一版包含一些新的章节,专门讲述SQL在应用服务器体系结构中的作用、sQL与xML的集成......一起来看看 《SQL完全手册》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具