Skip to content

Commit

Permalink
Merge pull request #1 from sematext/v1.1
Browse files Browse the repository at this point in the history
Allow reindexing from remote cluster
  • Loading branch information
radu-gheorghe authored Sep 27, 2022
2 parents 2eb7816 + ecbc6ed commit fefafac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ java -jar solr-reindexer.jar\
-sourceCollection my_collection_v1\
-targetCollection my_collection_v2\
-uniqueKey id\
-zkAddress localhost:9983,localhost:2181\
-sourceZkAddress localhost:9983,localhost:2181\
-targetZkAddress zoo1:2181,zoo2:2181\
-skipFields _version_,text\
-retries 7\
-retryInterval 2000\
Expand All @@ -18,7 +19,7 @@ java -jar solr-reindexer.jar\
Only `sourceCollection` and `targetCollection` are mandatory.
The rest are:
- `uniqueKey`: we use a cursor to go over the data. The cursor requires to sort on the `uniqueKey` defined in the schema, which in turn defaults to `id`
- `zkAddress`: the Zookeeper host:port for SolrCloud. If there are more, comma-separate them
- `sourceZkAddress` and `targetZkAddress`: the Zookeeper host:port for SolrCloud (source and destination). If there are more, comma-separate them
- `skipFields`: we reindex all the stored and docValues fields by default. But some may be skipped, like the default `_version_` (which will break the reindex because it will cause a version conflict) or copyFields that are also stored (they'll duplicate the values, because you'll redo the copyField operation). Comma-separate multiple fields
- `retries` and `retryInterval`: if we encounter an exception, we wait for `retryInterval` millis and retry up to `retries` times
- `query`: you may not want to reindex everything with the default `*:*`
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'org.sematext'
version '1.0'
version '1.1'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sematext/solr/reindexer/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Input {

public Input(Context context) {
final List<String> zkServers = new ArrayList<>();
String[] zkAddresses = context.stringParams.get("zkAddress").split(",");
String[] zkAddresses = context.stringParams.get("sourceZkAddress").split(",");
for (String zkAddress: zkAddresses) {
zkServers.add(zkAddress);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sematext/solr/reindexer/Output.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Output {

public Output(Context context) {
final List<String> zkServers = new ArrayList<>();
zkServers.add(context.stringParams.get("zkAddress"));
zkServers.add(context.stringParams.get("targetZkAddress"));
client = new CloudSolrClient.Builder(zkServers, Optional.empty())
.build();

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/sematext/solr/reindexer/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ private static void parseCmdLine(String[] args) throws ParseException {
.desc( "Interval between retries in milliseconds. Defaults to 5000" )
.hasArg(true)
.build());
options.addOption(Option.builder( "zkAddress")
.desc( "Zookeeper addresses for SolrCloud. Defaults to 'localhost:2181'. Comma-separate multiple addresses" )
options.addOption(Option.builder( "sourceZkAddress")
.desc( "Zookeeper addresses for source SolrCloud. Defaults to 'localhost:2181'. Comma-separate multiple addresses" )
.hasArg(true)
.build());
options.addOption(Option.builder( "targetZkAddress")
.desc( "Zookeeper addresses for target SolrCloud. Defaults to 'localhost:2181'. Comma-separate multiple addresses" )
.hasArg(true)
.build());
options.addOption(Option.builder( "query")
Expand Down Expand Up @@ -93,7 +97,8 @@ private static void parseCmdLine(String[] args) throws ParseException {
setIntegerParam("rows", 1000);
setIntegerParam("retries", 10);
setIntegerParam("retryInterval", 5000);
setStringParam("zkAddress", "localhost:2181");
setStringParam("sourceZkAddress", "localhost:2181");
setStringParam("targetZkAddress", "localhost:2181");
setStringParam("query", "*:*");
setStringParam("uniqueKey", "id");
setStringParam("sourceCollection", null);
Expand Down

0 comments on commit fefafac

Please sign in to comment.