File tree Expand file tree Collapse file tree 5 files changed +175
-0
lines changed Expand file tree Collapse file tree 5 files changed +175
-0
lines changed Original file line number Diff line number Diff line change
1
+ [CmdletBinding ()]
2
+ Param (
3
+ [Parameter (Mandatory = $True , HelpMessage = " Enter the Elasticsearch server Url. eg: http://localhost:9200/" )]
4
+ [string ]$ElasticServerUrl ,
5
+
6
+ [Parameter (Mandatory = $True , HelpMessage = " Enter index name. Eg: code* for all code indices or a specific index name" )]
7
+ [string ]$IndexName
8
+ )
9
+
10
+ function OptimizeIndex
11
+ {
12
+ $optimizeCommand = $ElasticServerUrl + $IndexName + " /_forcemerge?only_expunge_deletes=true"
13
+ $response = Invoke-RestMethod $optimizeCommand - Method Post - ContentType " application/json" - Credential (Get-Credential )
14
+ }
15
+
16
+ Write-Host - ForegroundColor Red @"
17
+ The optimize index operation you are going to execute will expunge all deleted documents of a given index.
18
+ This operation could cause very large shards to remain on disk until all the documents present in the index are just deleted documents.
19
+ Proceed with this operation if and only if it is absolutely required.
20
+ "@
21
+
22
+ Write-Host " Do you want to continue - Yes or No? " - NoNewline - ForegroundColor Magenta
23
+ $userInput = Read-Host
24
+
25
+ if ($userInput -like " Yes" )
26
+ {
27
+ Write-Host " Starting optimize index operation.." - ForegroundColor Green
28
+ OptimizeIndex
29
+ Write-Host " Initiated optimize operation.This operation executes at the background and will auto complete." - ForegroundColor Green
30
+
31
+ }
32
+ else
33
+ {
34
+ Write-Warning " Exiting! No optimize operation was performed for the given index." - ForegroundColor Cyan
35
+ }
Original file line number Diff line number Diff line change
1
+ [CmdletBinding ()]
2
+ Param (
3
+ [Parameter (Mandatory = $True , HelpMessage = " Enter the Elasticsearch server Url. eg: http://localhost:9200/" )]
4
+ [string ]$ElasticServerUrl ,
5
+
6
+ [Parameter (Mandatory = $True , HelpMessage = " Enter index name. Eg: code* for all code indices or a specific index name" )]
7
+ [string ]$IndexName
8
+ )
9
+
10
+ function OptimizeIndex
11
+ {
12
+ $optimizeCommand = $ElasticServerUrl + $IndexName + " /_forcemerge?only_expunge_deletes=true"
13
+ $response = Invoke-RestMethod $optimizeCommand - Method Post - ContentType " application/json" - Credential (Get-Credential )
14
+ }
15
+
16
+ Write-Host - ForegroundColor Red @"
17
+ The optimize index operation you are going to execute will expunge all deleted documents of a given index.
18
+ This operation could cause very large shards to remain on disk until all the documents present in the index are just deleted documents.
19
+ Proceed with this operation if and only if it is absolutely required.
20
+ "@
21
+
22
+ Write-Host " Do you want to continue - Yes or No? " - NoNewline - ForegroundColor Magenta
23
+ $userInput = Read-Host
24
+
25
+ if ($userInput -like " Yes" )
26
+ {
27
+ Write-Host " Starting optimize index operation.." - ForegroundColor Green
28
+ OptimizeIndex
29
+ Write-Host " Initiated optimize operation.This operation executes at the background and will auto complete." - ForegroundColor Green
30
+
31
+ }
32
+ else
33
+ {
34
+ Write-Warning " Exiting! No optimize operation was performed for the given index." - ForegroundColor Cyan
35
+ }
Original file line number Diff line number Diff line change
1
+ [CmdletBinding ()]
2
+ Param (
3
+ [Parameter (Mandatory = $True , HelpMessage = " Enter the Elasticsearch server Url. eg: http://localhost:9200/" )]
4
+ [string ]$ElasticServerUrl ,
5
+
6
+ [Parameter (Mandatory = $True , HelpMessage = " Enter index name. Eg: code* for all code indices or a specific index name" )]
7
+ [string ]$IndexName
8
+ )
9
+
10
+ function OptimizeIndex
11
+ {
12
+ $optimizeCommand = $ElasticServerUrl + $IndexName + " /_forcemerge?only_expunge_deletes=true"
13
+ $response = Invoke-RestMethod $optimizeCommand - Method Post - ContentType " application/json" - Credential (Get-Credential )
14
+ }
15
+
16
+ Write-Host - ForegroundColor Red @"
17
+ The optimize index operation you are going to execute will expunge all deleted documents of a given index.
18
+ This operation could cause very large shards to remain on disk until all the documents present in the index are just deleted documents.
19
+ Proceed with this operation if and only if it is absolutely required.
20
+ "@
21
+
22
+ Write-Host " Do you want to continue - Yes or No? " - NoNewline - ForegroundColor Magenta
23
+ $userInput = Read-Host
24
+
25
+ if ($userInput -like " Yes" )
26
+ {
27
+ Write-Host " Starting optimize index operation.." - ForegroundColor Green
28
+ OptimizeIndex
29
+ Write-Host " Initiated optimize operation.This operation executes at the background and will auto complete." - ForegroundColor Green
30
+
31
+ }
32
+ else
33
+ {
34
+ Write-Warning " Exiting! No optimize operation was performed for the given index." - ForegroundColor Cyan
35
+ }
Original file line number Diff line number Diff line change
1
+ [CmdletBinding ()]
2
+ Param (
3
+ [Parameter (Mandatory = $True , HelpMessage = " Enter the Elasticsearch server Url. eg: http://localhost:9200/" )]
4
+ [string ]$ElasticServerUrl ,
5
+
6
+ [Parameter (Mandatory = $True , HelpMessage = " Enter index name. Eg: code* for all code indices or a specific index name" )]
7
+ [string ]$IndexName
8
+ )
9
+
10
+ function OptimizeIndex
11
+ {
12
+ $optimizeCommand = $ElasticServerUrl + $IndexName + " /_forcemerge?only_expunge_deletes=true"
13
+ $response = Invoke-RestMethod $optimizeCommand - Method Post - ContentType " application/json" - Credential (Get-Credential )
14
+ }
15
+
16
+ Write-Host - ForegroundColor Red @"
17
+ The optimize index operation you are going to execute will expunge all deleted documents of a given index.
18
+ This operation could cause very large shards to remain on disk until all the documents present in the index are just deleted documents.
19
+ Proceed with this operation if and only if it is absolutely required.
20
+ "@
21
+
22
+ Write-Host " Do you want to continue - Yes or No? " - NoNewline - ForegroundColor Magenta
23
+ $userInput = Read-Host
24
+
25
+ if ($userInput -like " Yes" )
26
+ {
27
+ Write-Host " Starting optimize index operation.." - ForegroundColor Green
28
+ OptimizeIndex
29
+ Write-Host " Initiated optimize operation.This operation executes at the background and will auto complete." - ForegroundColor Green
30
+
31
+ }
32
+ else
33
+ {
34
+ Write-Warning " Exiting! No optimize operation was performed for the given index." - ForegroundColor Cyan
35
+ }
Original file line number Diff line number Diff line change
1
+ [CmdletBinding ()]
2
+ Param (
3
+ [Parameter (Mandatory = $True , HelpMessage = " Enter the Elasticsearch server Url. eg: http://localhost:9200/" )]
4
+ [string ]$ElasticServerUrl ,
5
+
6
+ [Parameter (Mandatory = $True , HelpMessage = " Enter index name. Eg: code* for all code indices or a specific index name" )]
7
+ [string ]$IndexName
8
+ )
9
+
10
+ function OptimizeIndex
11
+ {
12
+ $optimizeCommand = $ElasticServerUrl + $IndexName + " /_forcemerge?only_expunge_deletes=true"
13
+ $response = Invoke-RestMethod $optimizeCommand - Method Post - ContentType " application/json" - Credential (Get-Credential )
14
+ }
15
+
16
+ Write-Host - ForegroundColor Red @"
17
+ The optimize index operation you are going to execute will expunge all deleted documents of a given index.
18
+ This operation could cause very large shards to remain on disk until all the documents present in the index are just deleted documents.
19
+ Proceed with this operation if and only if it is absolutely required.
20
+ "@
21
+
22
+ Write-Host " Do you want to continue - Yes or No? " - NoNewline - ForegroundColor Magenta
23
+ $userInput = Read-Host
24
+
25
+ if ($userInput -like " Yes" )
26
+ {
27
+ Write-Host " Starting optimize index operation.." - ForegroundColor Green
28
+ OptimizeIndex
29
+ Write-Host " Initiated optimize operation.This operation executes at the background and will auto complete." - ForegroundColor Green
30
+
31
+ }
32
+ else
33
+ {
34
+ Write-Warning " Exiting! No optimize operation was performed for the given index." - ForegroundColor Cyan
35
+ }
You can’t perform that action at this time.
0 commit comments