public class SolrImportExport extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ROWS_PER_FILE |
| Constructor and Description |
|---|
SolrImportExport() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearIndex(String solrUrl)
Remove all documents from the Solr index with the given URL, then commit and optimise the index.
|
static void |
exportIndex(String indexName,
File toDir,
String solrUrl,
String timeField,
boolean overwrite)
Exports all documents in the given index to the specified target directory in batches of #ROWS_PER_FILE.
|
static void |
exportIndex(String indexName,
File toDir,
String solrUrl,
String timeField,
String fromWhen,
boolean overwrite)
Exports documents from the given index to the specified target directory in batches of #ROWS_PER_FILE, starting at fromWhen (or all documents).
|
static void |
importIndex(String indexName,
File fromDir,
String solrUrl,
boolean clear)
Import previously exported documents (or externally created CSV files that have the appropriate structure) into the specified index.
|
static void |
main(String[] args)
Entry point for command-line invocation
|
public static final int ROWS_PER_FILE
public static void main(String[] args) throws org.apache.commons.cli.ParseException
args - command-line arguments; see help for descriptionorg.apache.commons.cli.ParseException - if the command-line arguments cannot be parsedpublic static void exportIndex(String indexName, File toDir, String solrUrl, String timeField, boolean overwrite) throws org.apache.solr.client.solrj.SolrServerException, SolrImportExportException, IOException
indexName - The index to export.toDir - The target directory for the export. Will be created if it doesn't exist yet. The directory must be writeable.solrUrl - The solr URL for the index to export. Must not be null.timeField - The time field to use for sorting the export. Must not be null.overwrite - If set, allow export files to be overwrittenorg.apache.solr.client.solrj.SolrServerException - if there is a problem with exporting the index.IOException - if there is a problem creating the files or communicating with Solr.SolrImportExportException - if there is a problem in communicating with Solr.public static void importIndex(String indexName, File fromDir, String solrUrl, boolean clear) throws IOException, org.apache.solr.client.solrj.SolrServerException, SolrImportExportException
indexName - the index to import.fromDir - the source directory. Must exist and be readable.
The importer will look for files whose name starts with indexNameand ends with .csv (to match what is generated by #makeExportFilename).
solrUrl - The solr URL for the index to export. Must not be null.clear - if true, clear the index before importing.overwrite - if true, skip _version_ field on import to disable Solr's optimistic concurrency functionalityIOException - if there is a problem reading the files or communicating with Solr.org.apache.solr.client.solrj.SolrServerException - if there is a problem reading the files or communicating with Solr.SolrImportExportException - if there is a problem communicating with Solr.public static void clearIndex(String solrUrl) throws IOException, org.apache.solr.client.solrj.SolrServerException
solrUrl - URL of the Solr core to clear.IOException - if there is a problem in communicating with Solr.org.apache.solr.client.solrj.SolrServerException - if there is a problem in communicating with Solr.public static void exportIndex(String indexName, File toDir, String solrUrl, String timeField, String fromWhen, boolean overwrite) throws org.apache.solr.client.solrj.SolrServerException, IOException, SolrImportExportException
indexName - The index to export.toDir - The target directory for the export. Will be created if it doesn't exist yet. The directory must be writeable.solrUrl - The solr URL for the index to export. Must not be null.timeField - The time field to use for sorting the export. Must not be null.fromWhen - Optionally, from when to export. See options for allowed values. If null or empty, all documents will be exported.overwrite - If set, allow export files to be overwrittenorg.apache.solr.client.solrj.SolrServerException - if there is a problem with exporting the index.IOException - if there is a problem creating the files or communicating with Solr.SolrImportExportException - if there is a problem in communicating with Solr.Copyright © 2017 DuraSpace. All rights reserved.