'Solr Cloud - node sync not happening when document added using CloudSolrClient

I have a SolrCloud setup with 2 nodes and 2 replicas. I am using CloudSolrClient (Java) to add a document. After adding the document programmatically, when I search for the document through the Solr console UI, I find the document in only 1 node. On the other node, until I reload the collection, it is not returned in the search.

String zkHosts = "zookeperhostname:9983";
String solrCollectionName = "my_coll";
SolrClient solrClient =  new CloudSolrClient.Builder().withZkHost(zkHosts).build();
((CloudSolrClient)solrClient).setDefaultCollection(solrCollectionName);

DocVO docVO = createDocumentVO();
List<DocVO> newDocVOList = new ArrayList<DocVO>();
newDocVOList.add(docVO);        
solrClient.addBeans(newDocVOList);
solrClient.commit();

Kindly let me know what I am missing here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source