elasticsearch 筆記

1,創建索引:

put blog
{
"settings":{
"number_of_shards":3,
"number_of_replicas":0
}
}

返回值爲:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "blog"
}

注:

"number_of_shards": 分片數
"number_of_replicas":副本數

2,elastic 創建索引完成後分片數是不可修改的,但是副本數是可以修改的

put blog/_settings
{
"number_of_replicas":1
}
返回值是:
{
"acknowledged": true
}

3,elastic 對索引的讀寫操作的限制:

blocks.read_only:true

blocks.read:true

blocks.write:true

4,該索引添加別名:

post _aliases
{
    "actions":[
        {
            "add":{
                "index":"blog",
                "alias":"blog_alias"
            }
        }
    ]
}

返回值:

{
"acknowledged": true
}

給多個索引添加統一個別名:

post _aliases
{
    "actions":[
        {
            "add":{
                "index":"blog",
                "alias":"blog_alias"
            }
        },
         {
            "add":{
                "index":"blog1",
                "alias":"blog_alias"
            }
        }
    ]
}
簡寫:
post _aliases
{
    "actions":[
        {
            "add":{"indices":["blog","blog1"],"alias":"blog_alias"
            }
        }
    ]
}
刪除索引別名:
post _aliases
{
    "actions":[
        {
            "remove":{
                "index":"blog",
                "alias":"blog_alias"
            }
        },
         {
            "remove":{
                "index":"blog1",
                "alias":"blog_alias"
            }
        }
    ]
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章