LiveWhale sites auto-generate sitemaps and robots.txt files to help external search engines find your content. However, we also have built-in tools for allowing visitors to search on your own calendar or website.
Setting up search
In LiveWhale Calendar, search is likely already set up for you: simply including <xphp var="lw_calendar_search" /> in your calendar template will place the search box wherever you like, and LWC does the rest.
In LiveWhale CMS, search is more fully customizable and uses widgets with a search argument to return various results. You can setup a new site search in two parts:
A search form that targets a specific page (in this case, /search)
<widgetid="123_pages"> <!-- show matches for title/keywords if exist --> <argid="search"><xphpvar="q"type="GET"/></arg> <argid="filter_mode">any</arg> <argid="filter"name="short_title"action="matches"><xphpvar="q"type="GET"/></arg> <argid="filter"name="ga_keywords"action="matches"><xphpvar="q"type="GET"/></arg> <argid="filter"name="keywords"action="matches"><xphpvar="q"type="GET"/></arg> <argid="fallback"><argid="filter"></arg></arg><!-- otherwise, clear the filter and fallback on just a widget search --> </widget>
How LiveWhale calculates search results
When LiveWhale returns search results, it’s not searching across the whole database—that would be resource-intensive and time-consuming. Rather, any time you create or edit content, LiveWhale indexes it—saving a distilled version of weighted keywords that can be more quickly scanned when you search. Here’s how that works:
Each content type (story, event, etc.) is configured to designate some fields as having a high indexing weight (e.g., title, keywords, URL) and other fields as having a low weight (e.g. description).
Custom fields are automatically included in search indexing at a low weight.
Widget output is excluded from indexing except in special circumstances where <arg id="allow_indexing">true</arg> is set. Widgets with inline header args will have their header text indexed.
Any content within a <title>, <h1>, or <h2> tag is indexed with a high weight, as is any content within <p class="intro"> or <div class="intro">.
Common stop words (e.g., a, an, the, our, we) are excluded from indexed content. (If you’re curious, the complete list is at /livewhale/core/modules/search/includes/stopwords.php.)
Special phrases like a person’s name (both Jane Smith and Smith, Jane) or the title of a department are additionally indexed as a complete phrase for high weighting as an exact phrase match.
Content is indexed with variants in order to allow misspelled search terms to match the desired content.
More about search queries
Searching supports modifiers like +, -, wildcards, and quoted phrases.
Searching supports fulltext searches (the default) and strict matching (exact or partial matches against content title only). You can manually enable strict mode with <arg id="search_mode">strict</arg> (or /search_mode/strict in the REST API) if you want to search only across titles.
Search terms with less than 3 characters, as well as common stop words, are not supported in fulltext searches and therefore individually handled in strict mode (i.e. against title).
When searching for events, certain terms such as day/week/month are excluded.
Search terms will automatically match certain spelling variants (singular vs. plural, misspellings).
Search results are weighted and sorted according to several rules involving: weight of indexed content, relative strength of exact or partial matches against title, relative strength of match against content url, nature of content (i.e. “homepage”, “department of”, etc. considered high weight). Results are returned according to a cumulative relevance score, taking into account all these rules.
If your question is “How can I get this particular content to be more highly-ranked?”, try including your preferred keywords in the title, summary/intro, URL, or h1/h2 tags. In LiveWhale CMS, you can also consider adding it to QuickAccess results or tweaking the settings of your search results widgets to add additional filtering.