Forum

Thread tagged as: Problem, Runway

Search Results For Collection

I realise I can't limit search results to a collection as yet, however I'm having an issue rendering search results for a collection when blog content is found first.

If I search for a keyword and that is found in a collection but not in blog content, the collection results are rendered, but if I search for a keyword that is in both blog content and a collection then the blog results get rendered and the collection results do not

Diagnostics:

Perch Runway: 3.0.1
Production mode: ()
Installed apps: content (3.0.1), assets (3.0.1), categories (3.0.1), perch_blog (5.5.1), perch_forms (1.9)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (406), perch2_blog_posts (14), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (1), perch2_category_counts (1), perch2_category_sets (1), perch2_collection_index (233), perch2_collection_items (27), perch2_collection_revisions (4), perch2_collections (2), perch2_content_index (738), perch2_content_items (117), perch2_content_locks (0), perch2_content_regions (5), perch2_forms (0), perch2_forms_responses (0), perch2_menu_items (10), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (4), perch2_page_templates (26), perch2_pages (10), perch2_resource_log (119), perch2_resource_tags (3), perch2_resources (42), perch2_resources_to_tags (6), perch2_settings (26), perch2_user_passwords (0), perch2_user_privileges (39), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content',
        'categories',
        'perch_blog',
        'perch_forms'
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: markitup
H1: 895ce35e7e6c7f92b9c206ad83b83a05
L1: b8e0f7cd814dce17db4311d25a624608
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
headerColour: #ffffff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.34: done
perch_blog_site_name:
headerScheme: light
update_runway_2.8.34: done
latest_version:
on_sale_version:
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_update: 5.0.1
perch_blog_post_url: /news/{postSlug}
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
perch_blog_comment_notify: 0
update_runway_3.0: done
siteOffline: 0
update_runway_3.0.1: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /Users/Toby/Sites/catch
PERCH_SCHEDULE_SECRET: 1bK6mcBYEmBNPksH
PERCH_DB_USERNAME: root
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: perch_catch_local
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: hello@creativemonster.co.uk
PERCH_EMAIL_FROM_NAME: Creative Monster
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/Toby/Sites/catch/admin
PERCH_CORE: /Users/Toby/Sites/catch/admin/core
PERCH_RESFILEPATH: /Users/Toby/Sites/catch/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_HTML5: 1
PERCH_TZ: UTC
PERCH_PRODUCTION_MODE:
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_ASSET_VERSION: 7ca631ef9a54e99e413a
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/Toby/Sites/catch/admin/templates
PERCH_TEMPLATE_FILTERS:
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_XHTML_MARKUP:
PERCH_RWD: 1
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_DEFAULT_BUCKET: default
PERCH_TRANSLATION_ASSIST:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_PRIV_ASSIST:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: markdown
Hosting settings

PHP: 7.0.13
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
MySQL server: 5.6.34
Free disk space: 16.96 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imap, gettext, mcrypt, pgsql, pdo_pgsql, igbinary, memcached
GD: Yes
ImageMagick: No
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PHP_FCGI_CHILDREN: 4
PWD: /Applications/MAMP/fcgi-bin
PHP_FCGI_MAX_REQUESTS: 200
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x2
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.13.fcgi
ORIG_PATH_TRANSLATED: /Users/Toby/Sites/catch/admin/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /admin/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.13.fcgi
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
REQUEST_URI: /admin/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /admin/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 55419
SCRIPT_FILENAME: /Users/Toby/Sites/catch/admin/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/Toby/Sites/catch
REMOTE_ADDR: ::1
SERVER_PORT: 8888
SERVER_ADDR: ::1
SERVER_NAME: loc.catch
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: PHPSESSID=6d8f9d9c28643ee07cdaefaa734d06e8; cmsa=1
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://loc.catch:8888/admin/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: keep-alive
HTTP_HOST: loc.catch:8888
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
FCGI_ROLE: RESPONDER
PHP_SELF: /admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1491855877.04
REQUEST_TIME: 1491855877
argc: 1
Toby Martin

Toby Martin 1 points

  • 4 years ago

My search code:

if (perch_get('q')) {
    $query = perch_get('q');

    perch_content_search($query, array(
      'from-path' => '/opportunities',
      'count'     => 5
    ));
}

Search Template at it's most basic:

<perch:before>
  <h1>Search results for “<perch:search id="search_key" />”</h1>
</perch:before>

<a href="<perch:search id="result_url" />"><perch:search id="result_title" /></a>

<perch:if exists="result_excerpt">
  <p class="excerpt">…<perch:search id="result_excerpt" encode="false" />…</p>
</perch:if>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you tried <perch:showall /> in your template?

Yes, it only shows results for blog.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does debug output for the problematic query?

This is for the search term 'microsoft'

Time    Δ   Debug Message - Perch Runway 3.0.1
0.0342  0   [10] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
0.0378  0.0035  Matched page: /opportunities/search, so not using routes.
0.0378  0.0001  Using master page: /templates/pages/search.php
0.0414  0.0036  [1] SELECT * FROM perch2_pages WHERE pagePath='/opportunities/search' LIMIT 1
0.0424  0.0011  Using template: /templates/pages/attributes/default.html
0.0426  0.0001  Using sub-template: /templates/pages/attributes/seo.html
0.0428  0.0002  Search term: microsoft
0.0433  0.0006  [26] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
0.0537  0.0104  [2] SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, MATCH(ci.itemSearch) AGAINST('microsoft') 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('microsoft') OR MATCH(ci.itemSearch) AGAINST('microsoft') ) AND r.regionPage LIKE '/opportunities%' UNION SELECT 'PerchContent_RunwaySearch' AS source, MATCH(ci.itemSearch) AGAINST('microsoft') AS score, c.collectionKey AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, c.collectionOptions AS col4, c.collectionKey AS col5, c.collectionKey AS col6, collectionTemplate AS col7, c.collectionKey AS col8 FROM perch2_collections c, perch2_collection_items ci, perch2_collection_revisions cr WHERE c.collectionID=cr.collectionID AND cr.itemID=ci.itemID AND cr.itemRev=ci.itemRev AND c.collectionSearchable=1 AND cr.itemSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('microsoft') OR MATCH(ci.itemSearch) AGAINST('microsoft') ) UNION SELECT 'PerchBlog_SearchHandler' AS source, MATCH(postTitle, postDescRaw, postTags) AGAINST('microsoft') AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", "" FROM perch2_blog_posts p, perch2_blog_sections s WHERE postStatus='Published' AND postDateTime<'2017-04-11 08:32:53' AND p.sectionID=s.sectionID AND MATCH(postTitle, postDescRaw, postTags) AGAINST('microsoft') ORDER BY score DESC LIMIT 0, 5
0.0581  0.0043  [2] SELECT FOUND_ROWS() AS `count`
0.0583  0.0003  [2] Using template: /templates/search/search-result.html
0.0592  0.0009  Request time: 0.0592
0.0592  0   Process time: 0.0579
0.0593  0   Memory: 2.8399
Drew McLellan

Drew McLellan 2638 points
Perch Support

So you're getting 2 results - are they both from Blog?

Yes, but there should be 4: 2 from blog and 2 from the Opportunities collection.

If I restrict search to just Runway using 'apps' => ['PerchContent_RunwaySearch'] then I get just the 2 results from the collection

Drew McLellan

Drew McLellan 2638 points
Perch Support

You're working with so little content, I do wonder if this is just an artefact of the search algorithm. Will you be adding more content?

Yes, I'm just building out the site at the mo and made a start on search yesterday. I'll add more items to the collection later on today and see if it makes any difference. I would of thought search would perform better on less data though?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, full text search works very poorly with small data sets. It does things like exclude terms that match more than 50% of the results, which is very easy to hit when you only have small sets.

As search is only really needed once you have more content than you can browse, it's optimised for large sets, not small.