-
Notifications
You must be signed in to change notification settings - Fork 6
HowTo: SWB Verbunddaten prozessieren
Vorraussetzungen:
- ElasticSearch-Server
- SWB-Verbunddaten (Norm- und Titeldaten) im binären MARC21 Format
1. Transformieren der MARC21-Binärdaten ins MarcXchange line-delimited JSON-Format und Einspielen in Elasticsearch
Tools:
- efre-lod-elasticsearch-tools / helperscripts / marc2jsonl.py
- efre-lod-elasticsearch-tools / helperscripts / fix_mrc_id.py
- esbulk
marc2jsonl.py nutzt die aus xbib/marc stammende marcXchange Marc21->Json serialisierung um binäres MARC21 als line-delimited JSON zu serialisieren, dabei werden sämtliche Werte in Arrays gespeichert, auch die PPN. Das Python-script fix_mrc_id.py speichert die PPN als einfachen Wert und nicht mehr in einem Array. Beide Tools arbeiten mit stdin/stdout.
Zuerst müssen die Indices vorbereitet werden.
Es wird ein Rohdaten-Index für die Normdaten angelegt, dabei wird die Datumserkennung abgeschalten, da Datumsangaben in den SWB Verbunddaten ziemlich inkonsistent sind und die Datums-Erkennung von Elasticsearch zu Fehler führen kann, was zum Abbruch führt, außerdem wird die Limitierung der Felder-Anzahl höher gesetzt, aufgrund der zahlreichen Felder von Marc21:
curl -XPUT http://localhost:9200/swb-aut/ -d '{"mappings":{"'mrc'":{"date_detection":false}}}' -H "Content-Type: application/json"
curl -XPUT http://localhost:9200/swb-aut/_settings -d '{"index.mapping.total_fields.limit":5000}' -H "Content-Type: application/json"
Dasselbe für die Titeldaten:
curl -XPUT http://localhost:9200/swb-tit/ -d '{"mappings":{"'mrc'":{"date_detection":false}}}' -H "Content-Type: application/json"
curl -XPUT http://localhost:9200/swb-tit/_settings -d '{"index.mapping.total_fields.limit":5000}' -H "Content-Type: application/json"
Transformation der Marc21 Authority Rohdaten zu JSON und einspielen in ein Elasticsearch-Index. Als id-feld wird die PPN (001) gewählt.
marc2jsonl.py < swb-aut.mrc | fix_mrc_id.py | esbulk -server http://localhost:9200 -index swb-aut -type mrc -id 001 -w 8
marc2jsonl.py < swb-tit.mrc | fix_mrc_id.py | esbulk -server http://localhost:9200 -index swb-tit -type mrc -id 001 -w 8
Tools:
- efre-lod-elasticsearch-tools / processing / esmarc.py
- esbulk
esmarc.py -server http://localhost:9200/swb-aut/mrc
zieht die Daten aus dem Index, wendet ein Mapping an und speichert die Daten pro Entität. Im ldj Unterordner befinden sich weitere Unterordner, in denen die chunks verteilt sind. orga: Organisationen geo: Geographika resources: Werke persons: Personen
Diese können per esbulk in eigene Indices geladen werden:
cd ldj
curl -XPUT http://localhost:9200/orga/ -d '{"mappings":{"schemaorg":{"date_detection":false}}}' && cat orga/* | esbulk -server http://localhost:9200 -index orga -type schemaorg -id identifier; done
curl -XPUT http://localhost:9200/works/ -d '{"mappings":{"schemaorg":{"date_detection":false}}}' -H "Content-Type: application/json" && cat works/* | esbulk -server http://localhost:9200 -index works -type schemaorg -id identifier; done
curl -XPUT http://localhost:9200/geo/ -d '{"mappings":{"schemaorg":{"date_detection":false}}}' && -H "Content-Type: application/json" cat geo/* | esbulk -server http://localhost:9200 -index geo -type schemaorg -id identifier; done
curl -XPUT http://localhost:9200/persons/ -d '{"mappings":{"schemaorg":{"date_detection":false}}}' -H "Content-Type: application/json" && cat persons/* | esbulk -server http://localhost:9200 -index persons -type schemaorg -id identifier; done
Tools:
- efre-lod-elasticsearch-tools / processing / esmarc.py
- esbulk
esmarc -server http://localhost:9200/swb-tit/mrc
Erstellt ebenso 4 Ordner, allerdings sind die Dateien in den Normdaten-Ordner leer. Im resources Ordner befinden sich die Titeldatensätze.
Diese können per esbulk in einen eigenen Index geladen werden
cd ldj
curl -XPUT http://localhost:9200/resources/ -d '{"mappings":{"schemaorg":{"date_detection":false}}}' -H "Content-Type: application/json" && cat resources/* | esbulk -server http://localhost:9200 -index resources -type schemaorg -id identifier; done
Tools:
- efre-lod-elasticsearch-tools / processing / ldj2rdf.py
ldj2rdf.py erstellt aus dem in den Indices gespeicherten JSON-LD RDF im N-Triple Format.