The content rendered on the Website should not be affected by index rebuild. A solution to that is to setup Solr in a way that it will rebuild an index in a separate core so that the rebuilding does not affect the search index that is currently used. Once the rebuilding and the optimization of the index completes, Sitecore switches the two cores, and the rebuilt and optimized index is used.
I will describe the implementation steps with Sitecore 8.2 and Solr 5.3.1. I don’t expect this to be different with newer version.
Duplicate Solr index
Copy index folder (1) and rename it by adding _rebuild (2) suffix to the original name.

Figure 1 Copy index folder
Update Core configuration file

Figure 2 New index Folder
Open core.properties file from new _rebuild index folder (Figure 2 New Index Folder) and change name property to new index name (Figure 3 New Index core properties file).

Figure 3 New Index properties file
Add new core to Solr
Steps to add a new index to Solr (Figure 4 Adding new index to Solr)
- Open Solr console
- Go to Core Admin tab
- Click on Add Core button
- Paste new Index Folder Name (index will have the same name as its folder )
- Paste new Index Folder Name
- Click on Add Core button

Figure 4 Adding new index to Solr
Verify if primary and secondary indexes work by visiting these URLs:
http://localhost:8983/solr/%5Bindex_name%5D/select/?q=*
http://localhost:8983/solr/%5Bindex_name%5D_rebuild/select/?q=*
For exemple
- http://localhost:8983/solr/sitecore_globalsearch_index/select/?q=*
- http://localhost:8983/solr/sitecore_globalsearch_index_rebuild/select/?q=*
Separate cores for each index in Sitecore

Figure 5 Modify Sitecore Index Configuration
Steps to modify
- Open Index definition configuration file
- Replace the SolrSearchIndex class by its extended SwitchOnRebuildSolrSearchIndex class
- Add rebuild core param with <param desc=”rebuildcore”>$(id)_rebuild</param> param between <param desc=”core”>$(id)</param> and <param desc=”propertyStore” ref=”contentSearch/indexConfigurations/databasePropertyStore” param1=”$(id)” />