The OpenCities Site Search module allows visitors to search your site for relevant content. You can specify what content is available through your site search and take action to ensure popular or relevant pages are readily available in search results. For example, you can use Best Bets to attach a page to a popular keyword, ensuring that the page is first in your search results. You can also ensure your team writes meaningful content and uses common search terms and metadata, as you would optimize your site for search engines.
However, our site search prioritizes some forms of content over others. The rest of this article will discuss how our search returns results; please check out Set up internal site search for instructions on configuring your site search.
How site search works
When using the default site search, if a user enters a keyword into the site search, the site will filter by the content types included for the search, then search and order results by relevancy to the keyword. Our search will crawl content pages and look for the keyword, variations of the keyword (such as different tenses for the keyword), and the frequency of the keyword. The search will prioritize fields on content pages in this order:
- Page title
- Short description or summary
- Common search terms
- Body content
So, a keyword in the title of a page is ranked higher than the same keyword appearing in the body content; the page with the keyword in your page's title will then be higher in your search results. Additionally, keywords get matched based on the following criteria in priority order:
- Exact match
- Partial match
- The proximity of keywords to each other if it's a phrase search
- The number of occurrences on a page and the general distribution of the keyword in the index.
For limited-release Solr users, our main site search is improved, and we are working on the search function for listing pages. With Solr, the site search will also match keywords based on stemming (e.g., "families" stems from "family"), synonyms (e.g., "garbage" and "waste"), compound words (e.g., "wellbeing"), and phonetics (e.g., "colours" and "colors").
For example, if a site visitor searches for "recycle dispose", our search will return the following:
- Pages with both keywords
- Pages with either keyword
- Pages with keyword variations (recycling, disposal, recycled, etc.)
The sorting order for the search results will then depend on the exact phrase match, the number of times it occurs on the page, and the keyword's position on the page.
Our search will look for the combination of letters in the keyword, not necessarily the word as a whole. For example, searching for "pet" will also return the word "petition", and "park" will return "parking."
Lastly, a note about our predictive search; when a user searches a keyword, our predictive search will list the top 4 results and a link to your search results page. Predictive results will only display after three characters have been entered.
Documents and site search
You can enable documents in your files library to appear in your site search, but they will almost always be given lower priority than content pages because we expect site visitors to visit a page to find the document they're looking for.
We recommend making files available by either adding them to relevant pages and adding the file name to the common search terms field or using Document Libraries. Hosting files on a content page allows you to provide additional information or instructions that the site visitor may need about the document. This way, users can determine if it's the correct file, allowing them the option to download it.
How search works on listing pages
Some listing pages contain a search function that includes a keyword search and filter options. The filter options are always based on a single field on the content page, such as the categories, dates, or locations.
The keyword search functions the same way that site search does, but exclusively for the content presented in the listing.
Additionally, some lists for specific content types use aspects of that content type to prioritize pages. For example, the events listing will prioritize upcoming dates.
Troubleshooting and tips
- Double-check that the page's content type is included in your site search settings if your page isn't appearing in search results.
- Additionally, make sure that the setting to Hide this page from search isn't checked in the page's Settings tab.
- Search results are returned by the best match for the search term, so if your page doesn't include the words in the search term, it won't show up in the results. The search algorithm looks for the search term in the following order: title, summary or short description, keywords, body content, then other fields (such as side panels). Put keywords into these fields to improve the chances of a site search finding your page.
- If you are still having trouble, there are a couple of things you can do:
- Add keywords into the Add common search terms people would use when looking for this content field. This page field is on all content pages on your site and is found under the Supporting information menu on the Overview tab of the page.
- Use Best Bets to pair keywords with pages on your site to bump up those pages in your search results.
- OpenCities is a responsive platform, meaning some page elements will move around when switching between devices to maximize accessibility and display on smaller screens. The site search will always appear in the site's header, but search functions on content lists will be moved to an accordion at the bottom of mobile and tablet screens.