Does the maxTime of '-1' mean that automatic soft commits are off? If so, would I get the same result if I deleted the tag altogether? And if I have to manually do the soft commits, can that be done with 'commitWithin' (I googled this but got conflicting answers)?

1 Answer
1

First off, you can see the expression ${solr.autoSoftCommit.maxTime:-1} within the tag. This allows you to make use of Solr's variable substitution. That feature is described in detail here in the reference. If that variable has not been substituted by any of those means -1 is taken as value for that configuration.

Turning commitMaxTime to -1 effectively turns autocommit off. If you have a look at the relevant code below, you can see that commitMaxTime overrules any value of maxDocs, as the scheduleCommitWithin method returns immediately. I have not found this behaviour documented, so I looked up the code.

private void _scheduleCommitWithin(long commitMaxTime) {
if (commitMaxTime <= 0) return;
synchronized (this) {
if (pending != null && pending.getDelay(TimeUnit.MILLISECONDS) <= commitMaxTime) {
// There is already a pending commit that will happen first, so
// nothing else to do here.
// log.info("###returning since getDelay()==" + pending.getDelay(TimeUnit.MILLISECONDS) + " less than " + commitMaxTime);
return;
}
if (pending != null) {
// we need to schedule a commit to happen sooner than the existing one,
// so lets try to cancel the existing one first.
boolean canceled = pending.cancel(false);
if (!canceled) {
// It looks like we can't cancel... it must have just started running!
// this is possible due to thread scheduling delays and a low commitMaxTime.
// Nothing else to do since we obviously can't schedule our commit *before*
// the one that just started running (or has just completed).
// log.info("###returning since cancel failed");
return;
}
}
// log.info("###scheduling for " + commitMaxTime);
// schedule our new commit
pending = scheduler.schedule(this, commitMaxTime, TimeUnit.MILLISECONDS);
}
}

To the second part of your question, if you remove the tag all together this will have the same result as setting the value to -1. As you can see below, if the xpath expression returns null, you will get -1 as default value.

But removing the whole expression from the configuration will also remove the option to override that configuration via Solr's variable substitution.