Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit c3eb54c

Browse files
authored
Merge pull request #1 from geocodeearth/strict_content_type_checking
set json request header to avoid errors in es6+
2 parents 4caae95 + 0ddc640 commit c3eb54c

12 files changed

+54
-26
lines changed

add_replica.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ replica_count="${replica_count:-1}"
88

99
echo "setting replica count to $replica_count on $index_name index in $cluster_url"
1010

11-
curl -XPUT "$cluster_url/$index_name/_settings" -d "{
12-
\"index\" : {
13-
\"number_of_replicas\" : $replica_count
14-
}
11+
curl -XPUT "$cluster_url/$index_name/_settings" \
12+
-H 'Content-Type: application/json' \
13+
-d "{
14+
\"index\" : {
15+
\"number_of_replicas\" : $replica_count
16+
}
1517
}"

count_types.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ echo "counting all types on $cluster_url"
66

77
# query for all source values with an aggregation
88
# this requires fielddata to be loaded, which takes a bit of memory
9-
curl -s -XPOST "$cluster_url/pelias/_search?size=0" -d '{
9+
curl -s -XPOST "$cluster_url/pelias/_search?size=0" \
10+
-H 'Content-Type: application/json' \
11+
-d '{
1012
"aggs" : {
1113
"source_count" : { "terms" : { "field" : "source" } }
1214
}
@@ -15,7 +17,9 @@ curl -s -XPOST "$cluster_url/pelias/_search?size=0" -d '{
1517

1618
# query for all layer values with an aggregation
1719
# this requires fielddata to be loaded, which takes a bit of memory
18-
curl -s -XPOST "$cluster_url/pelias/_search?size=0" -d '{
20+
curl -s -XPOST "$cluster_url/pelias/_search?size=0" \
21+
-H 'Content-Type: application/json' \
22+
-d '{
1923
"aggs" : {
2024
"layer_count" : { "terms" : { "field" : "layer", "size": 20 } }
2125
}

enable_slowlog.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ set -euo pipefail
44
cluster_url="${cluster_url:-http://localhost:9200}"
55
echo "enabling slowlog for searching and indexing on $cluster_url"
66

7-
curl -XPUT "$cluster_url/_cluster/settings" -d '{
7+
curl -XPUT "$cluster_url/_cluster/settings" \
8+
-H 'Content-Type: application/json' \
9+
-d '{
810
"persistent": {
911
"index.search.slowlog.threshold.query.warn": "10s",
1012
"index.search.slowlog.threshold.query.info": "5s",

increase_bulk_thread_pool.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ set -eu
33

44
cluster_url="${cluster_url:-http://localhost:9200}"
55
echo "setting threadpool.bulk.queue_size to 500 on $cluster_url"
6-
curl -XPUT ${cluster_url}/_cluster/settings -d '{ "transient" : { "threadpool.bulk.queue_size" : 500 } }'
6+
curl -XPUT ${cluster_url}/_cluster/settings \
7+
-H 'Content-Type: application/json' \
8+
-d '{ "transient" : { "threadpool.bulk.queue_size" : 500 } }'

load_snapshot.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ new_snapshot_name="${new_snapshot_name:-pelias-2017.11.18-001123}"
1414
read_only="${read_only:-true}"
1515

1616
# create bucket, only needs to be run once
17-
curl -XPOST "$cluster_url/_snapshot/$es_repo_name" -d "{
17+
curl -XPOST "$cluster_url/_snapshot/$es_repo_name" \
18+
-H 'Content-Type: application/json' \
19+
-d "{
1820
\"type\": \"s3\",
1921
\"settings\": {
2022
\"bucket\": \"$s3_bucket\",
@@ -26,7 +28,9 @@ curl -XPOST "$cluster_url/_snapshot/$es_repo_name" -d "{
2628
}"
2729

2830
## import new snapshot with name including timestamp
29-
curl -XPOST "$cluster_url/_snapshot/$es_repo_name/${new_snapshot_name}/_restore" -d "{
31+
curl -XPOST "$cluster_url/_snapshot/$es_repo_name/${new_snapshot_name}/_restore" \
32+
-H 'Content-Type: application/json' \
33+
-d "{
3034
\"indices\": \"pelias\",
3135
\"rename_pattern\": \"pelias\",
3236
\"rename_replacement\": \"$new_snapshot_name\"

make_alias.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ index_name="${index_name:-pelias-2017.11.18-001123}"
66

77
echo "setting pelias alias to $index_name on $cluster_url"
88

9-
curl -XPOST "$cluster_url/_aliases" -d "{
9+
curl -XPOST "$cluster_url/_aliases" \
10+
-H 'Content-Type: application/json' \
11+
-d "{
1012
\"actions\": [{
1113
\"add\": {
1214
\"index\": \"$index_name\",

make_cluster_read_only.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ set -ue
44

55
cluster_url="${cluster_url:-http://localhost:9200}"
66

7-
curl -s -XPUT "$cluster_url/_cluster/settings" -d '{
7+
curl -s -XPUT "$cluster_url/_cluster/settings" \
8+
-H 'Content-Type: application/json' \
9+
-d '{
810
"persistent" : {
911
"cluster.blocks.read_only" : true
1012
}

make_cluster_read_write.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ set -ue
44

55
cluster_url="${cluster_url:-http://localhost:9200}"
66

7-
curl -s -XPUT "$cluster_url/_cluster/settings" -d '{
7+
curl -s -XPUT "$cluster_url/_cluster/settings" \
8+
-H 'Content-Type: application/json' \
9+
-d '{
810
"persistent" : {
911
"cluster.blocks.read_only" : false
1012
}

make_snapshot.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ s3_bucket="${s3_bucket:-pelias-elasticsearch.nextzen.org}"
2222

2323
# create Elasticsearch repository from settings
2424
set -x
25-
curl -XPOST "$cluster_url/_snapshot/$es_repo_name" -d "{
25+
curl -XPOST "$cluster_url/_snapshot/$es_repo_name" \
26+
-H 'Content-Type: application/json' \
27+
-d "{
2628
\"type\": \"s3\",
2729
\"settings\": {
2830
\"bucket\": \"$s3_bucket\",
@@ -32,7 +34,9 @@ curl -XPOST "$cluster_url/_snapshot/$es_repo_name" -d "{
3234
}"
3335

3436
# create snapshot
35-
curl -XPUT "$cluster_url/_snapshot/$es_repo_name/$new_snapshot_name" -d '{
37+
curl -XPUT "$cluster_url/_snapshot/$es_repo_name/$new_snapshot_name" \
38+
-H 'Content-Type: application/json' \
39+
-d '{
3640
"indices": "pelias"
3741
}'
3842

test/test_create_index.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
curl -XPUT "$cluster_url/twitter?pretty" -H 'Content-Type: application/json' -d'
5-
{
6-
"settings" : {
7-
"index" : {
8-
"number_of_shards" : 3,
9-
"number_of_replicas" : 2
10-
}
4+
curl -XPUT "$cluster_url/twitter?pretty" \
5+
-H 'Content-Type: application/json' \
6+
-d '{
7+
"settings" : {
8+
"index" : {
9+
"number_of_shards" : 3,
10+
"number_of_replicas" : 2
1111
}
12-
}
13-
'
12+
}
13+
}'
1414

1515
curl -XDELETE "$cluster_url/twitter"

0 commit comments

Comments
 (0)