Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
/vulcanizerPublic archive

Commita99df93

Browse files
authored
Merge pull request#102 from github/uyumazhakan/remove-ilm
Removing ILM Policy from Index is added
2 parents2b93a65 +b0aeb1f commita99df93

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

‎es.go‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,18 @@ func (c *Client) GetIndices(index string) ([]Index, error) {
710710
returnindices,nil
711711
}
712712

713+
// Get a subset of indices including hidden ones
714+
func (c*Client)GetHiddenIndices(indexstring) ([]Index,error) {
715+
varindices []Index
716+
err:=handleErrWithStruct(c.buildGetRequest(fmt.Sprintf("_cat/indices/%s?h=health,status,index,pri,rep,store.size,docs.count&expand_wildcards=open,closed,hidden",index)),&indices)
717+
718+
iferr!=nil {
719+
returnnil,err
720+
}
721+
722+
returnindices,nil
723+
}
724+
713725
// Get all the aliases in the cluster.
714726
//
715727
// Use case: You want to see some basic info on all the aliases of the cluster
@@ -1673,3 +1685,27 @@ func (c *Client) AllocateStalePrimaryShard(node, index string, shard int) error
16731685

16741686
returnnil
16751687
}
1688+
1689+
// RemoveIndexILMPolicy removes the ILM policy from the index
1690+
func (c*Client)RemoveIndexILMPolicy(indexstring)error {
1691+
agent:=c.buildPostRequest(fmt.Sprintf("%s/_ilm/remove",index))
1692+
1693+
_,err:=handleErrWithBytes(agent)
1694+
iferr!=nil {
1695+
returnerr
1696+
}
1697+
1698+
ilmHistoryIndices,err:=c.GetHiddenIndices(fmt.Sprintf("%s*.ds-ilm-history-*",index))
1699+
iferr!=nil {
1700+
returnerr
1701+
}
1702+
1703+
for_,ilmHistoryIndex:=rangeilmHistoryIndices {
1704+
err=c.DeleteIndex(ilmHistoryIndex.Name)
1705+
iferr!=nil {
1706+
returnerr
1707+
}
1708+
}
1709+
1710+
returnnil
1711+
}

‎es_test.go‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,3 +2212,24 @@ func TestAllocateStalePrimaryShard(t *testing.T) {
22122212
t.Fatalf("Unexpected error. expected nil, got %s",err)
22132213
}
22142214
}
2215+
2216+
funcTestRemoveIndexILMPolicy(t*testing.T) {
2217+
ilmRemoveTestSetup:=&ServerSetup{
2218+
Method:"POST",
2219+
Path:"/test-index/_ilm/remove",
2220+
}
2221+
getIndicesTestSetup:=&ServerSetup{
2222+
Method:"GET",
2223+
Path:"/_cat/indices/test-index*.ds-ilm-history-*",
2224+
Response:"[]",
2225+
}
2226+
2227+
host,port,ts:=setupTestServers(t, []*ServerSetup{ilmRemoveTestSetup,getIndicesTestSetup})
2228+
deferts.Close()
2229+
client:=NewClient(host,port)
2230+
2231+
err:=client.RemoveIndexILMPolicy("test-index")
2232+
iferr!=nil {
2233+
t.Fatalf("Unexpected error. expected nil, got %s",err)
2234+
}
2235+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp