| title | Gencon indexing (gencon_index) |
|---|---|
| author | Steven Ng |
| date | 2025-03-18 |
gencon_index is a Ruby-based CSV-to-Solr ingester for event data from past Gen Con gaming conventions. It reads CSV records, uses a configurable mapping file to translate source columns into Solr fields, builds Solr documents, and submits those records to Apache Solr for indexing.
Requires Ruby. Version specified in .ruby-version file.
This indexer targets SolrCloud. A local SolrCloud is included in this repo via
docker-compose.yml and the Solr configset in solr/gencon50-solr.
Install the gem dependencies (generally we do this in an rvm gemset)
bin/setup
Create the local environment file
cp .env.example .env
Set SOLR_URL in .env to the current Gencon50 collection or alias URL.
For local development, make load-data expects the local Docker SolrCloud settings from .env.example.
gencon_index loads .env for CLI usage. For local development, use the default local SolrCloud settings:
SOLR_PORT=8090
SOLR_HOSTNAME=localhost
SOLR_HOST=http://${SOLR_HOSTNAME}:${SOLR_PORT}
SOLR_COLLECTION=gencon50-dev
SOLR_URL=${SOLR_HOST}/solr/${SOLR_COLLECTION}
Start the local SolrCloud services:
make up
Load the checked-in CSV data from ./csv into the local collection:
make load-data
Send a commit to the configured Solr endpoint:
make commit
make load-data bootstraps the local SolrCloud state for this repo from solr/gencon50-solr. It waits for Solr, prepares the configset from solr/gencon50-solr, creates the local collection and alias if needed, and then ingests the CSV files.
make load-data ingests the CSV files in ./csv into the local gencon50-dev collection.
SOLR_URLis the Solr endpoint used bygencon_indexfor harvest and commit operations.SOLR_AUTH_USERandSOLR_AUTH_PASSWORDare used for HTTP basic auth bymake load-data,make commit, and thegencon_indexCLI when they are set.GENCON_TEMP_PATHoverrides the default directory used bybundle exec gencon_index harvest_all.
bundle exec gencon_index harvest_all uses these defaults unless flags override them:
--directory:GENCON_TEMP_PATHwhen set, otherwise./csv--pattern:*.csv--mapfile:solr_map.yml
Example:
GENCON_TEMP_PATH=/tmp/gencon bundle exec gencon_index harvest_all
For a separate SolrCloud instance, such as ansible-playbook-solrcloud, start from the external-cluster example env file:
cp .env.solrcloud.example .env
Update the values in .env for the target cluster:
SOLR_SCHEMEshould match the target SolrCloud protocol when it is nothttp.SOLR_HOSTNAMEshould be the hostname for the target SolrCloud instance.SOLR_AUTH_USERandSOLR_AUTH_PASSWORDare used for authenticated Solr admin and update requests.SOLR_HOSTshould remain credential-free base Solr host and port.SOLR_URLis the endpoint used by the CLI for ingest/commit.SOLR_PORTshould match the published Solr port for that environment.SOLR_COLLECTIONshould be the target collection or alias name.
make load-data uses SOLR_HOST for Solr admin endpoints and passes SOLR_AUTH_USER / SOLR_AUTH_PASSWORD separately for HTTP basic auth when they are set.
Example:
SOLR_SCHEME=http
SOLR_HOSTNAME=solrcloud.example.org
SOLR_AUTH_USER=solr
SOLR_AUTH_PASSWORD=changeme
SOLR_HOST=${SOLR_SCHEME}://${SOLR_HOSTNAME}:${SOLR_PORT}
SOLR_COLLECTION=gencon50-v3.0.1
SOLR_URL=${SOLR_HOST}/solr/${SOLR_COLLECTION}
When using an external SolrCloud, this repo assumes the target collection or alias already exists.
Run the executable directly from the repo
bundle exec gencon_index help
make load-data, make commit, and the gencon_index CLI use SOLR_AUTH_USER / SOLR_AUTH_PASSWORD for HTTP basic auth when they are set. SOLR_URL should remain the target Solr endpoint for ingest and commit requests.
Input CSV files must be UTF-8 encoded.
If a source file was saved with a Windows encoding such as Windows-1252, convert it to UTF-8 before running gencon_index:
iconv -f WINDOWS-1252 -t UTF-8 input.csv > output.utf8.csv
You can then load the converted file with:
bundle exec gencon_index harvest --mapfile=solr_map.yml output.utf8.csv
To seed the database with a CSV file from the command line, use the following command. Replace path/to/datafile.csv
with the path to the file to upload.
bundle exec gencon_index harvest --mapfile=solr_map.yml PATH/TO/datafile.csv
bundle exec gencon_index harvest_all
Defaults:
--directoryusesGENCON_TEMP_PATHwhen set, otherwise./csv--patterndefaults to*.csv--mapfiledefaults tosolr_map.yml
For the repo’s standard local workflow, use make load-data.
bundle exec gencon_index makemap --id=ID --map=solr_map.yml PATH/TO/datafile.csv
bundle exec gencon_index blconfig --output=_blacklight_config.rb solr_map.yml
bundle exec gencon_index commit --solr-url=http://localhost:8090/solr/gencon50-dev
Or:
make commit
Start local SolrCloud services
make up
Load all checked-in CSVs from ./csv into the local collection
make load-data
Send a commit to Solr
make commit
Test gencon_index
make test
Lint gencon_index
make lint