Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOLR: What does an autoSoftCommit maxtime of -1 mean?

Tags:

solr

Here's the default setting from my solrconfig.xml file:

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

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)?

Oh, and I'm using Solr 4.5.0

like image 446
Wrael Avatar asked Nov 21 '13 20:11

Wrael


People also ask

What is the meaning of Solr?

Solr is a popular search platform for Web sites because it can index and search multiple sites and return recommendations for related content based on the search query's taxonomy. Solr is also a popular search platform for enterprise search because it can be used to index and search documents and email attachments.

What is Solrconfig XML in Solr?

The solrconfig. xml file is the configuration file with the most parameters affecting Solr itself. While configuring Solr, you'll work with solrconfig. xml often, either directly or via the Config API to create "configuration overlays" ( configoverlay. json ) to override the values in solrconfig.

What is new searcher in Solr?

Related to the indexing in Solr: the Searcher (actually IndexSearcher as of Solr4) is the Solr / Lucene internal to the indexing and searching backend component, as you call it. The idea is that when you index documents in Solr, they become visible upon commit operation has finished.

What is the purpose of field analysis in Solr?

Field analysis tells Solr what to do with incoming data when building an index. A more accurate name for this process would be processing or even digestion, but the official name is analysis. Consider, for example, a biography field in a person document.


1 Answers

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);
    }
}

Taken from https://github.com/apache/lucene-solr/blob/lucene_solr_4_5/solr/core/src/java/org/apache/solr/update/CommitTracker.java

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.

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));
}

Taken from https://github.com/apache/lucene-solr/blob/lucene_solr_4_5/solr/core/src/java/org/apache/solr/core/SolrConfig.java

like image 82
cheffe Avatar answered Sep 23 '22 15:09

cheffe