Upgrading Splunk has no effect on your indexed data.
Ideally, there should be no data loss while upgrading indexers. However, do consider taking backups before upgrading the indexers as a best practice. So if there are any sudden failures, your data still can be restored from the backup.
Please refer to https://docs.splunk.com/Documentation/Splunk/8.0.6/Indexer/Backupindexeddata for more information.
Upgrading Splunk has no effect on your indexed data.