Data written to LindormSearch becomes searchable only after acommit operation. You can configure when a commit occurs. Two types of commits are supported: soft commit and hard commit.
Configuration in solrconfig.xml
When you create an index, you must specify aconfiguration set. You can use thesolrconfig.xml file in the configuration set to control index data visibility. To obtain thesolrconfig.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, this occurs 15 seconds after the 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, this occurs 30 seconds after the data is written.
Note-
The soft commit interval must be shorter than the hard commit interval.
-
Avoid setting a short interval. Frequent commits can degrade write performance because the server must constantly perform refreshes and open new searchers. Use the default values.
-
Apply the changes
-
Download the configuration set that you want to modify. For instructions, see Update a configuration set.
-
Modify the intervals for
soft commitandhard commit. -
Update the configuration set.
./solr zk upconfig -d conf/ -n myconf -
On the Collections page, select the target collection, and then click Reload.
Client parameters
To control data visibility without modifying the solrconfig.xml file on the server, you can explicitly call a commit operation when you write 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.