Data that is synchronized to the search engine service LindormSearch is visible only after the data is committed. You can specify the time when the data is committed by using one of the following methods: soft commit or hard commit.

Configure the solrconfig.xml file

You must configure the configuration set named config set when you create an index. You can use the solrconfig.xml file in the configuration set to control the index data visibility. For more information about how to obtain the solrconfig.xml file, see Update the configuration set.
  • soft commit
    <autoSoftCommit>
      <maxTime>${solr.autoSoftCommit.maxTime:15000}</maxTime>
    </autoSoftCommit>
                            

    By default, data is available for queries 15 seconds after a soft commit is executed.

  • hard commit
    <autoCommit>
      <maxTime>${solr.autoCommit.maxTime:30000}</maxTime>
      <openSearcher>false</openSearcher>
    </autoCommit>
                            

    By default, data is flushed to the disk 30 seconds after a hard commit is executed.

    Note
    • A soft commit consumes less time than a hard commit.
    • We recommend that you specify a sufficient amount of time. Otherwise, LindormSearch frequently flushes data to the disk. This affects write performance. Use the default value.

How it takes effect

  1. Download the configuration set that you want to modify. For more information, see Update the configuration set.

  2. Modify the time of the soft commit and the hard commit.

  3. Update the configuration set.
    ./solr zk upconfig -d conf/ -n myconf
                        
  4. Reload Collection image-03

Client parameters

If you do not want to modify the solrconfig.xml file on the server, you can explicitly call the commit method to make the data visible when you separately write the data to LindormSearch.

  • commitWithinMs
    // The second parameter commitWithinMs can be used to control the time when the current data is available for queries.
    public UpdateResponse add(SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException;
    For example, you can specify that data is available for queries 10 seconds after the data is synchronized to LindormSearch. 
    cloudSolrClient.add(doc, 1000); 
                        
  • commit API
    // After data is synchronized to LindormSearch, you can explicitly call the commit method to specify the time when the data is committed by the server to make sure that the data is available for queries.
    public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean softCommit) throws SolrServerException, IOException;
    For example, you can specify that the server immediately executes a soft commit. 
    cloudSolrClient.commit(false, false, true);
                        

Reference

For more information, see Official documentation.