I'm trying to find a way to display the number of resuts in a solr search. I need to display it in search-results template.

Thanks for any hint


The link given is a nice one to deal with the default search result number count. In Apache Solr you can use the following code to get the total number of documents returned in the search result.

if (apachesolr_has_searched() && ($response = apachesolr_static_response_cache())) {
  $returned_doc_num = $response->response->numFound;
  • Actually I only used $GLOBALS['pager_total_items'][0] as I have a pagination system. – Kangt_qc Jul 23 '14 at 16:59
  • That is fine I hope, but never used it. But you can use the numFound in templates as well. Check drupal.org/node/1516462 comment #4, #6 & #8 – Aneek Mukhopadhyay Jul 23 '14 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.