首先,你可以看到标签内表达${solr.autoSoftCommit.maxTime:-1}
。这使您可以使用Solr的变量替换。详细描述该功能here in the reference。如果该变量未被任何这些手段取代,则将-1
作为该配置的值。
将commitMaxTime设置为-1可以有效地关闭自动提交。如果您查看下面的相关代码,可以看到commitMaxTime
否决了maxDocs
的任何值,因为scheduleCommitWithin方法立即返回。我没有发现这种行为记录,所以我查了代码。
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);
}
}
从https://github.com/apache/lucene-solr/blob/lucene_solr_4_5/solr/core/src/java/org/apache/solr/update/CommitTracker.java
带到你的问题的第二部分,如果你删除标记都在一起,这将有相同的结果值设置为-1。正如你在下面看到的,如果xpath表达式返回null,你会得到-1作为默认值。
但是从配置中删除整个表达式还将删除通过Solr的变量替换覆盖该配置的选项。
protected UpdateHandlerInfo loadUpdatehandlerInfo() {
return new UpdateHandlerInfo(get("updateHandler/@class",null),
getInt("updateHandler/autoCommit/maxDocs",-1),
getInt("updateHandler/autoCommit/maxTime",-1),
getBool("updateHandler/autoCommit/openSearcher",true),
getInt("updateHandler/commitIntervalLowerBound",-1),
getInt("updateHandler/autoSoftCommit/maxDocs",-1),
getInt("updateHandler/autoSoftCommit/maxTime",-1),
getBool("updateHandler/commitWithin/softCommit",true));
}
从https://github.com/apache/lucene-solr/blob/lucene_solr_4_5/solr/core/src/java/org/apache/solr/core/SolrConfig.java
采取