SOLR-6067: add methods to reduce code duplication in SolrIndexSearcher, Grouping

For ticket https://issues.apache.org/jira/i#browse/SOLR-6067 - baselined against trunk (previous pull request was against branch_4x).