2013-11-21 60 views
11

這裏是默認的從我的solrconfig.xml中文件設置:SOLR:-1的autoSoftCommit maxtime是什麼意思?

<autoSoftCommit> 
    <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime> 
</autoSoftCommit> 

是否的MAXTIME「-1」意味着自動軟提交熄滅?如果是這樣,如果我完全刪除了標籤,我會得到相同的結果嗎?如果我必須手動進行軟提交,可以用'commitWithin'來完成(我使用了這個,但得到了相互矛盾的答案)?

哦,我使用的Solr 4.5.0

回答

16

首先,你可以看到標籤內表達${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

採取