Skip to content

Instantly share code, notes, and snippets.

@cwilper
Last active October 5, 2016 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwilper/c94a75db5e3f65e658028f84cdd731ab to your computer and use it in GitHub Desktop.
Save cwilper/c94a75db5e3f65e658028f84cdd731ab to your computer and use it in GitHub Desktop.

Manual Solr Dump and Load via CSV

Solr has built-in CSV export and import facilities, which can be used to copy data from one core to another.

You can use the following process to select documents from one core and move them to another, using only the Solr Admin UI, Chrome, and curl.

Dump CSV from source core

  1. Use the Solr Admin UI's Query screen to formulate a query for the subset of documents you want to dump.
  2. Run the query and click on the link that gives you the raw query results.
  3. In the URL bar, change the wt=json part to wt=csv and hit enter.
  4. Copy the entire first line of the output and append it to the URL, preceded by &fl=.
  5. Remove ,_version_ from the fl value. This will prevent dumping the document version, ensuring that the destination Solr instance does not interpret your upload request as a modification request.
  6. In Chrome, go the Developer Tools, then the Network tab, and reload the page.
  7. Right click on the URL in the network tab and select Copy as cURL.
  8. Paste this in your terminal, but don't hit enter yet.
  9. Move your cursor to the url passed to curl, and add or modify the rows= value in the URL to the maximum number of records you want (tip: you can also add or change the start= value as needed to aid in dumping the solr documents in multiple pages).
  10. At the end of the command-line, append something like > dump.csv and hit enter.

Load CSV into destination core

Run something like the following, using the URL to your destination solr core:

curl http://localhost:8080/solr/statistics/update/csv --data-binary @dump.csv -H 'Content-type:text/plain; charset=utf-8'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment