This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
indexUtil.sh
150 lines (131 loc) · 3.46 KB
/
indexUtil.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#! /bin/bash
clusterName='es-data'
while [ "$1" != "" ]; do
case $1 in
--user )
shift
username=$1
;;
--env )
shift
environment=$1
;;
--index )
shift
indexName=$1
;;
--docType )
shift
documentType=$1
;;
--alias )
shift
alias=$1
;;
--docMappingFile )
shift
docMappingFile=$1
;;
--query )
shift
query=$1
;;
--update )
shift
updateFile=$1
;;
--file )
shift
file=$1
;;
--slices )
shift
slices=$1
;;
--watch )
shift
watch=$1
;;
*)
usage
exit 1
esac
shift
done
function usage() {
echo "createIndex --env <environment> --index <index name>"
}
function buildElasticSearchHostName() {
local _elasticSearchHostName=$1
local _env=$2
if [ "$_env" == 'local' ]; then
elasticSearchHostName='http://local.docker:9200/'
else
elasticSearchHostName='http://'"$clusterName"'.'"$_env"'.blackbaudcloud.com:9200/'
fi
eval $_elasticSearchHostName="'$elasticSearchHostName'"
}
function buildElasticSearchUrl() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
buildElasticSearchHostName elasticSearchHostName $_env
url="$elasticSearchHostName""$_idxName"
eval $_elasticSearchUrl="'$url'"
}
function buildElasticSearchCatUrl() {
local _elasticSearchUrl=$1
local _env=$2
buildElasticSearchHostName elasticSearchHostName $_env
url="$elasticSearchHostName"'_cat'
eval $_elasticSearchUrl="'$url'"
}
function buildElasticSearchReindexUrl() {
local _elasticSearchUrl=$1
local _env=$2
url='http://'"$clusterName"'.'"$_env"'.blackbaudcloud.com:9200/_reindex'
eval $_elasticSearchUrl="'$url'"
}
function buildElasticSearchUrlToAddNewField() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
local _docType=$4
url='http://'"$clusterName"'.'"$_env"'.blackbaudcloud.com:9200/'"$_idxName"'/_mapping/'"$_docType"
eval $_elasticSearchUrl="'$url'"
}
function buildSearchUrl() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
local _docType=$4
buildElasticSearchHostName elasticSearchHostName $_env
url="$elasticSearchHostName""$_idxName"'/'"$_docType"'/_search'
eval $_elasticSearchUrl="'$url'"
}
function buildAggregationsQueryUrl() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
local _docType=$4
buildElasticSearchHostName elasticSearchHostName $_env
url="$elasticSearchHostName""$_idxName"'/'"$_docType"'/_search'
eval $_elasticSearchUrl="'$url'"
}
function buildUpdateByQueryUrl() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
local _docType=$4
local _slices=$5
url='http://'"$clusterName"'.'"$_env"'.blackbaudcloud.com:9200/'"$_idxName"'/'"$_docType"'/_update_by_query'
eval $_elasticSearchUrl="'$url'"
}
function buildTasksUrl() {
local _elasticSearchUrl=$1
local _env=$2
local _idxName=$3
local _docType=$4
url='http://'"$clusterName"'.'"$_env"'.blackbaudcloud.com:9200/_tasks'
eval $_elasticSearchUrl="'$url'"
}