Index data visibility

Updated at:

Data written to LindormSearch becomes searchable only after a commit operation. You can configure when commits occur. LindormSearch supports two commit types: soft commit and hard commit.

Configuration in solrconfig.xml

When you create an index, you must specify a configuration set. The solrconfig.xml file in the configuration set controls index data visibility. To obtain the solrconfig.xml file, see Update a configuration set.

  • soft commit

    <autoSoftCommit>
      <maxTime>${solr.autoSoftCommit.maxTime:15000}</maxTime>
    </autoSoftCommit>
                            

    A soft commit makes data searchable. By default, a soft commit occurs 15 seconds after data is written.

  • hard commit

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

    A hard commit persists data to disk. By default, a hard commit occurs 30 seconds after data is written.

    Note
    • The soft commit interval must be shorter than the hard commit interval.

    • Avoid setting short intervals. Frequent commits can degrade write performance because the server must constantly refresh and open new searchers. Use the default values.

Apply the changes

  1. Download the configuration set that you want to modify. For instructions, see Update a configuration set.

  2. Modify the intervals for soft commit and hard commit.

  3. Update the configuration set.

    ./solr zk upconfig -d conf/ -n myconf
                        
  4. On the Collections page, select the target collection, and then click Reload.

Client parameters

Instead of modifying the server-side solrconfig.xml file, you can explicitly call a commit operation when writing data to LindormSearch.

  • commitWithinMs

    // The commitWithinMs parameter specifies how long (in milliseconds) to wait after adding
    // a document before it becomes searchable.
    public UpdateResponse add(SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException;
    // Example: Makes the data searchable within 1,000 milliseconds (1 second).
    cloudSolrClient.add(doc, 1000); 
                        
  • commit API

    // After you write data, explicitly call the commit API to ensure that the data becomes searchable.
    public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean softCommit) throws SolrServerException, IOException;
    // Example: The server immediately performs a soft commit.
    cloudSolrClient.commit(false, false, true);
                        

References

For more information, see the official documentation.