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.
- Use the Solr Admin UI's Query screen to formulate a query for the subset of documents you want to dump.
- Run the query and click on the link that gives you the raw query results.
- In the URL bar, change the
wt=json
part towt=csv
and hit enter. - Copy the entire first line of the output and append it to the URL, preceded by
&fl=
. - Remove
,_version_
from thefl
value. This will prevent dumping the document version, ensuring that the destination Solr instance does not interpret your upload request as a modification request. - In Chrome, go the Developer Tools, then the Network tab, and reload the page.
- Right click on the URL in the network tab and select Copy as cURL.
- Paste this in your terminal, but don't hit enter yet.
- 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 thestart=
value as needed to aid in dumping the solr documents in multiple pages). - At the end of the command-line, append something like
> dump.csv
and hit enter.
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'