Group search results by content type and limit count I am trying to group search results by its content type. Also, I want to show not more than 4 results per content type.

For an assumption, it should look like this:
Content type1-
  Result1
  Result2
  Result3
  Result4
Content type2-
  Result5
  Result6
...

I am able to achieve this using TEMPLATE_preprocess_search_results().

function custom_preprocess_search_results(&amp;$variables) {
  $variables['search_results'] = '';
  $resultTypes = array();

  // Divide results
  foreach ($variables['results'] as $result) {
    $resultTypes[$result['bundle']][] = $result;   
  }

  // Create fieldsets
  foreach ($resultTypes as $resultType =&gt; $resultTypeResults) {
    $value = '';
    $i = 0;

    foreach ($resultTypeResults as $result) {
      $value .= theme('search_result', array('result' =&gt; $result, 'module' =&gt; $variables['module']));
      $i++;
      if ($i == 4) {
        $value .= l(t('Show more'), current_path(), array('query' =&gt; array()));
        break;
      }
    }

  $variables['search_results'] .= theme('fieldset', array('element' =&gt; array('#title' =&gt; $resultType, '#children' =&gt; $value));
  }
}


But this is not an optimal method, since I trimmed down the results per content type (but actually they exist). Say if Content type1 has 10 actual results and Solr's maximum results per page is set to 10, then I will end up showing first 4 results of only Content type1.

Please suggest an ideal method to list 'n' matched results of every content type.

Thanks!
You can increase the page limit by apache solr hook 

function custom_apachesolr_query_alter($query) {
  if(strpos($_SERVER['REQUEST_URI'],'/bundle/') == false)
    {
  $query-&gt;replaceParam('rows', '400'); // Note that high value increases response time
  }
}