Files

CORDIS → Elasticsearch Crawler

Crawls the EU CORDIS data portal and imports its XLSX exports into Elasticsearch 8.x. A single run processes three funding programmes, in order:

  1. Horizon Europe (2021–2027) → cordis_eu_horizon_europe_*
  2. Horizon 2020 → cordis_eu_horizon_2020_*
  3. FP7 → cordis_eu_fp7_*

Each programme is fully indexed before the next one starts. Index names are the programme prefix + a dataset suffix, so the three programmes never collide.

Indices created (per programme, <prefix>_<suffix>)

Suffix Source HE H2020 FP7 Description
projects projects ZIP ✓ ✓ ✓ Core project data
organizations projects ZIP ✓ ✓ ✓ Participating organisations per project
topics projects ZIP ✓ ✓ ✓ Topic assignments per project
euroscivoc projects ZIP ✓ ✓ ✓ European Science Vocabulary classifications
legal_basis projects ZIP ✓ ✓ ✓ Legal basis per project
web_links projects ZIP ✓ ✓ ✓ Project website URLs
publications publications ✓ ✓ ✓ Peer-reviewed / other publications
deliverables deliverables ZIP ✓ ✓ — Project deliverables (FP7 has none)
report_summaries reports ZIP ✓ ✓ ✓ Periodic and final publishable summaries
erc_pis direct .xlsx — ✓ — ERC principal investigators (H2020 only)
project_iprs direct .xlsx — — ✓ Patents / IPRs per project (FP7 only)

Not every distribution is a ZIP: FP7 publications (FP7PC_DM_PROJ_PUBLICATIONS.xlsx) and IPRs (projectIrps_fp7.xlsx), and the H2020 ERC-PI file (cordis-h2020-erc-pi.xlsx) are downloaded as plain .xlsx. The downloader handles both shapes transparently.

CORDIS refreshes its data monthly. Each run performs a full re-index: every target index is dropped and recreated from scratch before new data is loaded.


Requirements

  • Python 3.10+
  • Elasticsearch 8.x (local, cloud, or self-hosted)

Quick start

# 1. Clone / copy the project
cd cordis_crawler

# 2. Create a virtual environment
python -m venv .venv
source .venv/bin/activate       # Windows: .venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Configure your Elasticsearch connection
cp .env.example .env
# Edit .env — set ES_HOST, ES_API_KEY (or ES_USER + ES_PASSWORD), etc.

# 5. Run the full crawl
python main.py

Configuration (.env)

Variable Default Description
ES_HOST https://localhost:9200 Elasticsearch endpoint
ES_API_KEY (empty) Preferred: API key (base64 id:key string)
ES_USER elastic Fallback basic-auth username
ES_PASSWORD (empty) Fallback basic-auth password
ES_CA_CERT (empty) Path to CA cert (self-signed TLS)
ES_VERIFY_SSL true Set false in dev if using self-signed certs
BATCH_SIZE 1000 Documents per Elasticsearch bulk request
DOWNLOAD_TIMEOUT 300 HTTP download timeout in seconds
TEMP_DIR /tmp/cordis_crawler Scratch space for ZIPs and extracted files

Generating an API key in Kibana

Stack Management → Security → API Keys → Create API key → copy the encoded value.


CLI usage

# Full run: all three programmes (Horizon Europe → H2020 → FP7), all datasets
python main.py

# Only one programme (or a subset, in the given order)
python main.py --programmes fp7
python main.py --programmes horizon_europe h2020

# Re-index only publications and deliverables (across all programmes)
python main.py --only publications deliverables

# Re-index the projects ZIP only (all 6 sub-indices, all programmes)
python main.py --only projects

# H2020 publications only
python main.py --programmes h2020 --only publications

# Parse and count rows without writing to ES
python main.py --dry-run

# Combine flags
python main.py --programmes fp7 --only reports --dry-run

Available programmes: horizon_europe, h2020, fp7 Available dataset labels: projects, publications, deliverables, reports, erc_pis, project_iprs

Datasets not offered by a programme are skipped automatically (e.g. FP7 has no deliverables; only H2020 has erc_pis; only FP7 has project_iprs).


How it works

main.py
  │  for programme in [Horizon Europe, Horizon 2020, FP7]:   ← run in order
  ↓
CORDIS API  (config.settings: one api_url per programme)
  │  GET /datasets/<programme>
  │  → classify each XLSX distribution by title → discovery key
  │    (downloader.classify_distribution: ipr / erc-pi before generic project)
  ↓
downloader.py
  │  HTTP stream → temp dir
  │    .zip  → unzip → extracted XLSX files
  │    .xlsx → use directly (FP7 publications/IPRs, H2020 ERC-PI)
  ↓
crawler/registry.py
  │  picks the right parser(s) per (programme, dataset)
  │  HE / H2020 share one parser set; FP7 has its own variants
  ↓
parsers/
  │  Base class reads XLSX with pandas (dtype=str to avoid type inference)
  │  Drops phantom empty rows; honours per-parser SHEET_NAME / COLUMN_RENAMES
  │  Projects ZIP router matches filename stem → correct parser
  ↓
transformer.py
  │  European float: "2073781,25" → 2073781.25
  │  Boolean coercion: "true" → True ; Integer parsing ; date sanitising
  │  clean_doc(): strips None / NaN / empty strings
  ↓
indexer.py
  │  recreate_index(): DELETE + PUT <prefix>_<dataset> with JSON mapping
  │  streaming_bulk(): batched bulk API requests
  ↓
Elasticsearch 8.x
    cordis_eu_horizon_europe_*   (projects, organizations, …, deliverables, report_summaries)
    cordis_eu_horizon_2020_*     (… + erc_pis)
    cordis_eu_fp7_*              (… + project_iprs, no deliverables)

Scheduling (monthly refresh)

Linux cron

# First Sunday of each month at 02:00
0 2 1-7 * 0  cd /opt/cordis_crawler && .venv/bin/python main.py >> /var/log/cordis_crawler.log 2>&1

Docker

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]

Extending for new CORDIS file types

  1. Add a JSON mapping under config/mappings/<name>.json.
  2. Register the dataset key → mapping filename in config/settings.py (DATASET_MAPPINGS), and add the discovery key to the relevant programmes in PROGRAMME_DATASETS.
  3. Create a parser in crawler/parsers/<name>.py inheriting BaseParser, with a DATASET_KEY matching the mapping key.
  4. Wire the parser into crawler/registry.py (_SINGLE_DEFAULT / _SINGLE_FP7, or _RELATION_ROUTER for a file inside the projects ZIP).
  5. If the distribution's title isn't matched by an existing keyword, extend downloader.classify_distribution().

Per-programme notes (field formatting)

  • Horizon Europe and Horizon 2020 share one schema and one parser set.
  • FP7 differs and uses dedicated parsers:
    • project.xlsx has an extra nature column, no keywords / Human-validated, and (unlike HE/H2020) keeps empty cells in place, so it needs no row-shift repair.
    • publications ship as a direct .xlsx (FP7PC_DM_PROJ_PUBLICATIONS.xlsx, sheet Export Worksheet) with UPPER_SNAKE_CASE columns, renamed to the shared publications schema (VOLUME/REPOSITORY_URL/QA_PROCESSED_DOI map to new volume/repositoryUrl/qaProcessedDoi fields).
    • reportSummaries.xlsx has a real attachment column (no shift quirk).
    • euroSciVoc.xlsx leaves code as the root /, so the doc _id uses (projectID, code, path) rather than (projectID, code).
    • IPRs (projectIrps_fp7.xlsx, a direct .xlsx) → project_iprs.

Known data quirks

Issue Handling
European decimal format (2073781,25) transformer.parse_european_float() strips thousand-sep dots, swaps comma
Phantom empty rows at end of XLSX df.dropna(how='all') in BaseParser.parse()
Unnamed: N sentinel columns Filtered via df.columns.str.startswith("Unnamed") (kept only where a repair needs them)
id / rcn read as int64 by pandas BaseParser.make_id() coerces the chosen key to str before indexing
Human-validated column (hyphen in name) Renamed to humanValidated in ProjectsParser.COLUMN_RENAMES
CORDIS uses British spelling organisation The file is organization.xlsx; both stems route to the same parser
No natural key in the relation files (organisations, topics, euroSciVoc, legalBasis) Synthesised composite _id via BaseParser.composite_id() — e.g. organisations use projectID_organisationID_order, topics projectID_topic, euroSciVoc projectID_code_path, legalBasis projectID_legalBasis_uniqueProgrammePart
organisation.xlsx has an rcn, but it is the org entity id, not per-row (33k distinct over 136k rows) Not used as _id; composite key above keeps every participation row
legalBasis.xlsx column shift — when uniqueProgrammePart is blank, that cell is dropped and projectID slides left (~6.4k of 28.9k rows, leaving projectID empty) LegalBasisParser.repair_row() detects the empty projectID + numeric uniqueProgrammePart and shifts back
projectDeliverables.xlsx column shift — when url is blank that cell is dropped and url..collection slide left (~113 rows, rcn ends up non-numeric) DeliverablesParser.repair_row() realigns rows whose rcn is not numeric
reportSummaries.xlsx column shift — rows with attachments gain a leading file-paths cell, shifting everything right; the real rcn lands in an unlabelled 7th column (~4.9k of 9.1k rows) ReportSummariesParser sets KEEP_UNNAMED=True and repair_row() realigns from Unnamed: 6, splitting out an attachments field
projectPublications.xlsx column shift — an optional ISSN cell and other blanks shift rows by ±1–2 positions (5 distinct shift amounts over ~58k of 78k rows); two unlabelled trailing columns Every row carries the constant collection value "Project publication"; PublicationsParser.repair_row() anchors on it to realign the tail (doi, projectID, projectAcronym, collection, contentUpdateDate, rcn) and recovers publishedYear by value. Middle bibliographic fields are best-effort for the heavily-shifted minority
project.xlsx column shift — a blank ecSignatureDate drops that cell and slides ecSignatureDate..legalBasis left (1 row currently) ProjectsParser.repair_row() detects a non-date ecSignatureDate and shifts the tail back
Column-shift garbage landing in a date-mapped field (would make ES reject the doc) Belt-and-suspenders: BaseParser validates every declared DATE_FIELDS value via transformer.sanitize_date() and nulls anything that is not a date — no document is ever rejected on a date parse error
New projects-ZIP files policyPriorities.xlsx, webItem.xlsx Intentionally unmapped — logged as No parser found … skipping
FP7 euroSciVoc.xlsx code is the root / for every row — (projectID, code) would collapse ~46% of a project's classifications EuroSciVocParser.make_id() keys on (projectID, code, path); path is the real discriminator and is present for HE/H2020 too
webLink.xlsx id identifies the link resource, not the row — the same URL is shared across projects and recurs per source/type (479 collisions in FP7) WebLinksParser keeps the original id as linkId and builds the _id from a full-row content hash (BaseParser.content_id()); only truly-identical rows collapse
FP7 IPRs have no natural key and the same patent recurs with title variants in several languages Fp7IprsParser.make_id() uses a full-row content hash so every distinct row survives
FP7 direct-.xlsx distributions (FP7PC_DM_PROJ_PUBLICATIONS.xlsx, projectIrps_fp7.xlsx) and H2020 cordis-h2020-erc-pi.xlsx are not ZIPs downloader.fetch_and_extract() detects .xlsx vs .zip by extension and skips extraction for direct files
FP7 Project IPRs / Principal Investigators … ERC projects titles both contain "project" downloader.classify_distribution() tests ipr / principal investigator before the generic project keyword