Perch Search Returning Empty Results

  • I have the following code:

    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, )); ?>

    This returns no search results, even though the term used is matched across various pages and products.

    If I add the shop app to the list it returns shop products:

    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchShop'], )); ?>

    Does Perch Search page titles for standard pages? There are pages within the site that are exact matches for the search term entered.

  • Search results depend upon what you are displaying in the search results template - normally located in /perch/templates/search/search-result.html. You can, of course, customise this template to show whatever you like as long as it's in the search results.

    Add <perch:showall> to bottom of the template to see what's available to you.

    If you get zero or unexpected results then it's because Perch's search algorithm is tailored for larger data sets. You can use an external search engine like elasticsearch to expand your options.

  • OK, with a little bit more work I've got this working as I expected it to work.

    By explicitly adding the 'apps' I want it to search content within it works as expected.

    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchShop','PerchContent'], )); ?>

    The search now successfully finds content within the shop pages and the standard pages.

    Note: There is hardly any content in my site at this stage (some pages found only have titles and no text content), but it works perfectly.

    Hope this helps others when getting blank search results.

    Special thanks to this post: