2026-03-31 14:18:50 +02:00
2026-03-31 14:18:50 +02:00
2026-03-31 14:18:50 +02:00
2026-03-31 14:18:50 +02:00
2026-03-31 14:18:50 +02:00
2026-03-31 14:18:50 +02:00

OpenAlex → Elasticsearch

Bulk-index OpenAlex snapshot data (JSONL/gzip) into Elasticsearch.

Structure

├── elasticsearch/
│   ├── mappings.py      # Index mappings & transforms for all 21 entity types
│   └── upload.py        # Generic upload script (any entity)
├── requirements.txt
├── openapi.json         # OpenAlex OpenAPI 3.1.0 spec (reference)
└── .env                 # ES_USERNAME, ES_PASSWORD (not committed)

Setup

pip install -r requirements.txt

Configure credentials in .env:

ES_USERNAME=your_user
ES_PASSWORD=your_pass

Or use alternative auth via environment variables:

Variable Description
ES_URL Elasticsearch URL (default: http://localhost:9200)
ES_API_KEY ApiKey auth
ES_BEARER_TOKEN JWT bearer token
ES_USERNAME / ES_PASSWORD HTTP Basic auth

Usage

cd elasticsearch/

# Upload works
python upload.py --entity works --input ../works/

# Upload any entity
python upload.py --entity authors --input ../authors/
python upload.py --entity institutions --input ../institutions/

# Single file
python upload.py --entity awards --input ../awards/part_0000.gz

# Create all 21 indices without uploading
python upload.py --entity works --create-all-indices --create-index-only

# Custom batch size
python upload.py --entity works --input ../works/ --batch-size 1000

Supported entities

works, authors, sources, institutions, topics, domains, fields, subfields, sdgs, countries, continents, languages, keywords, publishers, funders, awards, concepts, work-types, source-types, institution-types, licenses

Mappings & Transforms

mappings.py defines ES mappings derived from the OpenAPI spec with these query optimizations:

Feature Applies to
search_as_you_type on title works
completion suggester on display_name works, authors, sources, institutions, topics, keywords, publishers, funders
rank_feature on cited_by_count works, authors
geo_point on geo.location institutions
text field for reconstructed abstract works

Ingestion transforms (applied automatically during upload):

  • works — reconstructs abstract from abstract_inverted_index
  • works, authors — copies cited_by_count to cited_by_count_rank
  • institutions — synthesizes geo.location as {lat, lon} from geo.latitude/geo.longitude
S
Description
openalex Elasticsearch: mappings and upload
Readme
112 MiB
Languages
Python 100%