Index Solr documents - Part 4 - GeoBlacklight Workshop"
Feb 9, 2015
Index Solr documents
GeoBlacklight uses GeoBlacklight-Schema as a template for metadata documents indexed by Solr.
GeoBlacklight provides a rake task to index documents as fixtures for tests. We will use this rake task to index several documents as an example.
Download fixture metadata documents
Create and move to a directory for your documents
$ mkdir -p spec/fixtures/solr_documents && cd spec/fixtures/solr_documents
Download some metadata documents (in JSON format) to the directory
$ curl -O https://gist.githubusercontent.com/mejackreed/84abc598927c43af665b/raw/geoblacklight-documents.json
Move back to app root directory
$ cd - # Or cd ../../../
Make sure your Solr server and Rails application are started.
$ rake geoblacklight:server
Index fixture metadata documents
Run the GeoBlacklight fixture indexer
$ rake geoblacklight:solr:seed
The GeoBlacklight Solr seed task, indexes metadata documents (in JSON format) stored in the
Optional Commit your work
$ git add . $ git commit -m 'Adds in JSON fixtures'
As stated above, this rake task is useful for quickly indexing a small number documents in Solr (built specifically for populating Solr for testing). I would caution though in using this task for large scale indexing and commiting, as we’ve developed other best practices for production-scale indexing.
Want to index some more documents? Check out this tutorial on how to easily index metadata from OpenGeoMetadata.
- Part 1 - GeoBlacklight overview
- Part 2 - Setting up your environment
- Part 3 - Create your application
- Part 4 - Index Solr documents
- Part 5 - Customize your application
This work is licensed under a Creative Commons Attribution 4.0 International License.