Skip to content

Commit

Permalink
Create new index and update alias in transformAndIndex.sh (RPB-109)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Jan 26, 2024
1 parent 6502199 commit 7c4f354
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion conf/rpb-titel-to-lobid.flux
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
default outfile = "conf/output/bulk/bulk-${i}.ndjson";
default index = "resources-rpb-test";
"conf/output/output-strapi.ndjson"
| open-file
| as-lines
| decode-json
| fix(FLUX_DIR + "rpb-titel-to-lobid.fix")
| batch-reset(batchsize="1000")
| encode-json(prettyPrinting="false")
| json-to-elasticsearch-bulk(idkey="id", type="resource", index="resources-rpb-test")
| json-to-elasticsearch-bulk(idkey="id", type="resource", index=index)
| write(outfile)
;
17 changes: 15 additions & 2 deletions transformAndIndex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@
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-$(date "+%Y%m%d-%H%M").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"
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"'" } }
]
}
'

0 comments on commit 7c4f354

Please sign in to comment.