Forum

Thread tagged as: Question, Problem

Question about search functionality

Hi,

I have a subdirectory within a site for support articles, the pages are generated through simple "list & detail" mode. I'm setting up a support search that should only pull in the pages from that support directory, and not other general pages, blog, etc…

I'm getting the odd blog post showing up in the support search, and I'm wondering if this might be because the blog (post) template and support (article) template I've created use the same ID's e.g. -

Blog post title id:

<perch:blog id="postTitle" type="text" label="Title" required="true" title="true" order="1" />

Support article title id:

<perch:content id="postTitle" type="text" label="Title" required="true" title="true" order="1" />

If you don't think this should be an issue, let me know and I can post diagnostics and code.

Thanks

Mark Heggan

Mark Heggan 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you limiting the search just to the Content app?

Hi Drew,

I'm using -

<?php

    $query = perch_get('q');

    perch_content_search($query, array(
        'from-path' => '/support',
        'apps' => 'content',
    ));

?>

But still getting blog posts through, here the debug from the page

SELECT * FROM perch2_pages WHERE pagePath='/support/search.php' LIMIT 1
0.0698  0.0009  SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/support/search.php' OR regionPage='*' ORDER BY regionPage DESC
0.0708  0.001   SELECT groupID FROM perch2_navigation WHERE groupSlug='primary-alt' LIMIT 1
0.0732  0.0024  SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.0758  0.0026  SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/support/search.php' LIMIT 1
0.0775  0.0017  Using template: /templates/navigation/primary_alt.html
0.0797  0.0022  Using template: /templates/search/search-form.html
0.0839  0.0043  Search term: wine
0.0857  0.0018  SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
0.092   0.0063  SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, MATCH(ci.itemSearch) AGAINST('wine') AS score, r.regionPage AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, r.regionOptions AS col4, p.pageNavText AS col5, p.pageTitle AS col6, regionTemplate AS col7, r.regionKey AS col8 FROM perch2_content_regions r, perch2_content_items ci, perch2_pages p WHERE r.regionID=ci.regionID AND r.regionRev=ci.itemRev AND r.pageID=p.pageID AND r.regionPage!='*' AND r.regionSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('wine') OR MATCH(ci.itemSearch) AGAINST('wine') ) AND r.regionPage LIKE '/support%' UNION SELECT 'PerchBlog_SearchHandler' AS source, MATCH(postTitle, postDescRaw, postTags) AGAINST('wine') AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", "" FROM perch2_blog_posts p, perch2_blog_sections s WHERE postStatus='Published' AND postDateTime<'2015-08-05 14:06:48' AND p.sectionID=s.sectionID AND MATCH(postTitle, postDescRaw, postTags) AGAINST('wine') ORDER BY score DESC LIMIT 0, 10
0.124   0.0319  SELECT FOUND_ROWS() AS `count`
0.126   0.002   Using template: /templates/search/search-result.html
0.136   0.01    SELECT groupID FROM perch2_navigation WHERE groupSlug='secondary' LIMIT 1
0.1464  0.0104  SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.1526  0.0062  SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/support/search.php' LIMIT 1
0.155   0.0024  Using template: /templates/navigation/secondary.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

That's supposed to be an array. Try:

'apps' => ['PerchContent'],

That's got it, cheers Drew. I'd assumed the array was only required when using multiple apps.

Are these app values documented anywhere? I had also assumed they would use the same values as the configuration for "app_list".

e.g. had I wanted content, blog and events to be included in the search, I would have assumed:

'apps' => ['content', 'perch_blog', 'perch_events'],

Just wanted to check for future reference, Thanks!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Both those are given as examples in the docs - it would be PerchBlog and PerchEvents. It's the names of the search handlers rather than the folders on the file system.

My apologies, those are exactly the examples used. I hadn't picked up on that when scanning the docs, but your explanation has helped me better understand what I'm actually doing with search now, so thanks!