Fixes text search and selected for "secured" documents

Fixes #2663.