-
Notifications
You must be signed in to change notification settings - Fork 0
/
transformAndIndex.sh
36 lines (32 loc) · 1.05 KB
/
transformAndIndex.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
#!/bin/bash
set -eu
IFS=$'\n\t'
TIME=$(date "+%Y%m%d-%H%M")
INDEX="resources-rpb-$TIME"
ALIAS="resources-rpb-test"
# Get the daily Allegro dump:
cd conf
wget http://www.rpb-rlp.de/rpb/rpb04/intern/RPBEXP.zip
unzip -o RPBEXP.zip
mv RPBEXP.zip RPBEXP/RPBEXP-$TIME.zip
cd ..
# Transform the data:
sbt "runMain rpb.ETL conf/rpb-sw.flux"
sbt "runMain rpb.ETL conf/rpb-titel-to-strapi.flux"
sbt "runMain rpb.ETL conf/rpb-titel-to-lobid.flux index=$INDEX"
# Index to Elasticsearch:
unset http_proxy # for posting to weywot3
curl -XPUT -H "Content-Type: application/json" weywot3:9200/$INDEX?pretty -d @../lobid-resources-rpb/src/main/resources/alma/index-config.json
for filename in conf/output/bulk/bulk-*.ndjson
do
echo "$filename"
curl -XPOST --header 'Content-Type: application/x-ndjson' --data-binary @"$filename" 'weywot3:9200/_bulk'
done
curl -X POST "weywot3:9200/_aliases?pretty" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "*", "alias" : "'"$ALIAS"'" } },
{ "add" : { "index" : "'"$INDEX"'", "alias" : "'"$ALIAS"'" } }
]
}
'