这是我的solrconfig.xml文件的默认设置:
<autoSoftCommit>
<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
</autoSoftCommit>
Run Code Online (Sandbox Code Playgroud)
maxTime为'-1'是否意味着自动软提交已关闭?如果是这样,如果我完全删除了标签,我会得到相同的结果吗?如果我必须手动执行软提交,可以使用'commitWithin'(我用Google搜索但是得到了相互矛盾的答案)吗?
哦,我正在使用Solr 4.5.0
che*_*ffe 18
首先,您可以${solr.autoSoftCommit.maxTime:-1}在标记中看到表达式.这允许您使用Solr的变量替换.该特征在参考文献中详细描述.如果该变量未被任何这些方法替换,则将其-1视为该配置的值.
将commitMaxTime设置为-1可以有效地关闭自动提交.如果您查看下面的相关代码,您可以看到,当scheduleCommitWithin方法立即返回时,它会commitMaxTime否决任何值maxDocs.我没有发现记录此行为,所以我查找了代码.
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);
}
}
Run Code Online (Sandbox Code Playgroud)
对于问题的第二部分,如果一起删除标记,则与将值设置为-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));
}
Run Code Online (Sandbox Code Playgroud)