Count and search (fixes #4579)