Plugin: Enable empty queries
Purpose
Use this plugin when you need to return a pre-polulated search results page, or set a default query to run when the user submits an empty query.
When to use this plugin
The most common usage case for this plugin is when you have a search results page on your website that you want to be able to visit, and have it return results when the page loads, before the user inputs their search terms.
This should only be used for search pages (with a search box), where you want to set a default query to run when the search is called.
This plugin allows you to tailor the query for a default search,
When not to use this plugin
Don’t use this plugin for pages that use the search to populate content dynamically (i.e. using the search index like a database to populate page content).
For this scenario you should create a dedicated results page that is configured for the content that is being returned to the page. The query is generally set by the caller (e.g. within a content management system) based on page-level attributes, so you don’t require a default query in this scenario.
Populating page content dynamically using the search often also uses a separate template as well as different ranking/sorting options and using a separate result page keeps all this configuration together and in a place that is independent of your site search.
You should always use a separate results page for non-search pages so that queries for this purpose are not included in your general search analytics. You can choose to collect analytics for these results pages if you want to. |
Usage
Enable the plugin
-
Select Plugins from the side navigation pane and click on the Enable empty queries tile.
-
From the Location section, select the results page to which you would like to enable this plugin from the Select a results page select list.
The plugin will take effect as soon as you finish running through the plugin setup steps. |
Configuration settings
The configuration settings section is where you do most of the configuration for your plugin. The settings enable you to control how the plugin behaves.
The configuration key names below are only used if you are configuring this plugin manually. The configuration keys are set in the results page configuration to configure the plugin. When setting the keys manually you need to type in (or copy and paste) the key name and value. |
Default query
Configuration key |
|
Data type |
string |
Default value |
|
Required |
This setting is optional |
Specifies a query to run when none is provided. The default is to return all documents. The value is a Funnelback query language string.
The default value for the default query makes use of the negation operator as a means to return all results. i.e. The default value of !FunDoesNotExist:padrenull translates to return all documents which does not have the metadata class FunDoesNotExist containing the fictitious word `padrenull`. As this is unlikely to be present in any document, so all documents are returned.
|
Examples
Funnelback supports various query operators which all can be used when specifying the default query.
Example: Show all media releases after a particular date
The following configuration demonstrates how to set the default query to return all media releases after 1 Jan 2021:
Default query |
|
where:
-
v:media-releases
means return all results that have the word 'media-releases' inside the path component of the URL. -
d>1jan2021
means return all results with a date after 1 Jan 2021
Example: Display only physics events
The following configuration demonstrates how to set the default query to return only results that have a metadata field type set to the value of event.
Default query |
|
where:
-
physics
means return all results that contain the word 'physics' -
|type:event
means scope the set of results to only items results that are of type:event