-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_fixtures.sh
executable file
·51 lines (41 loc) · 1.19 KB
/
setup_fixtures.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
#!/usr/bin/env bash
set -eo pipefail
function do_curl {
set -e
curl "$@"
}
function index {
json="$1"
do_curl http://localhost:9200/people/person -XPOST -H "Content-Type: application/json" -d "$json"
echo "indexed $json\n\n"
}
do_curl http://localhost:9200/people -XDELETE
echo "deleted index"
do_curl http://localhost:9200/people -XPUT
echo "created index"
json=$(cat <<EOD
{
"properties": {
"favoriteColor": {
"type": "keyword"
},
"username": {
"type": "keyword"
},
"locale": {
"type": "keyword"
},
"birthyear": {
"type": "number"
}
}
}
EOD
)
do_curl http://localhost:9200/people/_mapping/person -H "Content-Type: application/json" -d "$json"
m=$(echo $json | jq -c .)
echo "put field mappings: $m"
index '{ "type": "person", "favoriteColor": "red", "username": "John", "locale": "UK", "birthyear": 1940 }'
index '{ "type": "person", "favoriteColor": "blue", "username": "Paul", "locale": "UK", "birthyear": 1942 }'
index '{ "type": "person", "favoriteColor": "orange", "username": "George", "locale": "UK", "birthyear": 1943 }'
index '{ "type": "person", "favoriteColor": "red", "username": "Ringo", "locale": "UK", "birthyear": 1940 }'