Answers.Body: <p>I would try one of the following solutions:</p>
  <ol>
  <li><p><strong>Using Ajax to display the search results and the filter</strong></p>
  <p>Use ajax to display your search results. After loading the search results, you'r using a second Ajax call to get the categories filter. With this solution the visitor see the results quickly and get the filter after. You could try to including caching of the filter to speed up the page. Downside: Depending on requests and amount of content, it needs still a lot of server power.</p>
  </li>
  <li><p><strong>Writing your own Plugin</strong></p>
  <p>Write your own search filter plugin with your logic and optimized SQL to get the filter faster. This solution can be combined with the first one.</p>
  </li>
  <li><p><strong>Using a external Search Engine</strong></p>
  <p>A other solution could be to use a external search engine service like Google Custom Search. Some of them offers filters/logic like you need. Craft CMS Example: On <a href="https://straightupcraft.com/craft-plugins/" rel="nofollow noreferrer">https://straightupcraft.com/craft-plugins/</a> the search is provided by Algolia (<a href="https://www.algolia.com/" rel="nofollow noreferrer">https://www.algolia.com/</a>). On the right side is a simple developer filter, including number of entries.
  Take also a look at the Algolia Plugin to easy integrate Algolia in Craft CMS -&gt; <a href="https://straightupcraft.com/craft-plugins/search-plus-1" rel="nofollow noreferrer">https://straightupcraft.com/craft-plugins/search-plus-1</a></p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-24T15:47:24.573Z
Answers.LastActivityDate: 2016-04-24T15:47:24.573Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: Tom Bauer
Body: <p>I have a site with a few channels each with a lot of entries. When retrieving the results from a site search, I’d like to show a paginated list of entries from all sections by default, but then have filters in a sidebar which retrieve only entries from a certain channel, again in a paginated list.</p>
  
  <p>How can I initially show the total number of entries in each channel for a particular search term, without having to actually construct a query for each channel individually which would be really slow?</p>
  
  <p>The behaviour would be identical to the following example where it lists the number of entries for each ‘Material type’ <a href="http://explore.bl.uk/primo_library/libweb/action/search.do?dscnt=1&amp;tab=website_tab&amp;dstmp=1461161587439&amp;vl(freeText0)=family&amp;fn=search&amp;vid=BLVU1&amp;mode=Basic&amp;fromLogin=true" rel="nofollow">http://explore.bl.uk/primo_library/libweb/action/search.do?dscnt=1&amp;tab=website_tab&amp;dstmp=1461161587439&amp;vl(freeText0)=family&amp;fn=search&amp;vid=BLVU1&amp;mode=Basic&amp;fromLogin=true</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-21T09:44:41.497Z
Comments.Text: Even easily being able to identify which channels have at least one entry so the filter list only contains relevant channels would be good.
Comments.UserDisplayName: Alex H
Tags: <entries><search><pagination>
Title: How can I efficiently show the number of total results per channel when retrieving search results?
ThreadText: # How can I efficiently show the number of total results per channel when retrieving search results?
  
  (Asked by: username_0 on 2016-04-20)
  
  I have a site with a few channels each with a lot of entries. When retrieving the results from a site search, I’d like to show a paginated list of entries from all sections by default, but then have filters in a sidebar which retrieve only entries from a certain channel, again in a paginated list.
  
  How can I initially show the total number of entries in each channel for a particular search term, without having to actually construct a query for each channel individually which would be really slow?
  
  The behaviour would be identical to the following example where it lists the number of entries for each ‘Material type’ <http://explore.bl.uk/primo_library/libweb/action/search.do?dscnt=1&tab=website_tab&dstmp=1461161587439&vl(freeText0)=family&fn=search&vid=BLVU1&mode=Basic&fromLogin=true>
  
  **Tags:** entries, search, pagination
  
  > **Comments:**
  > **username_0**: Even easily being able to identify which channels have at least one entry so the filter list only contains relevant channels would be good.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-24. Score: 1
  
  I would try one of the following solutions:
  
  1. **Using Ajax to display the search results and the filter**
  
     Use ajax to display your search results. After loading the search results, you'r using a second Ajax call to get the categories filter. With this solution the visitor see the results quickly and get the filter after. You could try to including caching of the filter to speed up the page. Downside: Depending on requests and amount of content, it needs still a lot of server power.
  2. **Writing your own Plugin**
  
     Write your own search filter plugin with your logic and optimized SQL to get the filter faster. This solution can be combined with the first one.
  3. **Using a external Search Engine**
  
     A other solution could be to use a external search engine service like Google Custom Search. Some of them offers filters/logic like you need. Craft CMS Example: On <https://straightupcraft.com/craft-plugins/> the search is provided by Algolia (<https://www.algolia.com/>). On the right side is a simple developer filter, including number of entries.
     Take also a look at the Algolia Plugin to easy integrate Algolia in Craft CMS -> <https://straightupcraft.com/craft-plugins/search-plus-1>
  
  
  ---
  
  