You can use Post-Search Rules to examine the results of a search and determine how the search affects the displayed content.
If a search has no results, a Post-Search Rule can perform a search for a similar item. Or, it can display a web page that recommends other items to customers who search for the item that was not found.
Each Post-Search Rule consists of two main elements: the rule’s actions, and its optional conditions. You can specify an unlimited number of rules and conditions. The order of these rules is important because the rule set is looped through rule-by-rule. When a rule’s conditions match, all the associated actions are performed.
You can refine the set of search results for a maximum of three rounds of searching. After this, whatever is currently available is used. This limit prevents infinite loops and ensures that the customer receives an efficient response. The more times you redo a search the longer it takes to return your search results. If none of the matching rules alter one of the searches for the currently used presentation template or switch the template, the set of search results is considered finalized and post-search exits.
Post-search processing builds upon the earlier processing modules Query Cleaning and Pre-Search processing. Therefore, any custom variables set in those modules are available for use in the post-search processing rules. Similarly, pre-search processing has instantiated all of the templates where each named search associated with the presentation template has its own local copy of the CGI parameters. In turn, you can customize each search individually.
See About Query Cleaning Rules.
Conditions are optional. If you specify that actions are specified for every query, then the actions are always taken. You can base conditions on any CGI query parameter, cookie, search result, or custom variable that a previous rule has set. Or, you can base it on a system condition such as what the currently selected template is or if it is the last search. When you build a condition on the results of a search or a CGI parameter, you specify the template and the name of the search.
All of the actions in a Post-Search Rule that have matching conditions are exercised. Actions typically consist of an operation, the data to perform the operation on, and the value to use. The simplest action is to switch which Presentation template to use based on the Post-Search Rule’s conditions. You can use more advanced actions to change the parameters for a search that results in the search being redone. When performing an operation on a template’s search parameter, specify a Presentation template and search.
When performing operations on a template’s search parameter, two special values exist, *targeted and *primary for the Presentation template and the named search respectively. Use these values to build rules based on the current targeted template’s primary search. These constructs let you build generic rules where you do not need to worry about what the current targeted template or primary search are called. If this pass is the first through the post-search processing, the targeted template is whatever pre-search processing sets it to.
Direct Hits and redirects within Query Cleaning let you redirect to a URL based on the incoming search terms. Redirects within post-search rules extend this idea, except that it lets you check how many results that the search returned before deciding if you want a redirect to take place. With Post-Search Rules, you can redirect to a URL, where you can substitute custom variables or query parameters. Or, you can redirect to a field within the first result. When you redirect to a result’s field, you define the field in the Transport template, and it must contain a valid, explicit URL, otherwise the redirect is skipped.
When you use the redirect mechanism within Post-Search Rules , you can detect when a search returns a single result. Rather than returning such a result, you can redirect to the web page that is associated with the result.
See the redirect example below for an example of using redirects with Post-Search Rules.
When the conditions are met for a rule that has the option Last Rule set, the post search processing module does not perform any additional rules after the action of the matching rule. This situation is useful when you have set actions that cause a later rule to match but you want the processing to stop. And, for that later rule to potentially match after the next round of searching.
In the following example, assume that you have two presentation templates. One template is used to display many search results and the other template is used to display a single result and an additional search for accessories related to the main search. You want to detect when you have a single result and switch to your other presentation template. To accomplish this task, you can use the following rules:
On condition:
targeted template is default
targeted template primary results equal 1
not last search
Perform the following actions:
Set targeted template to product_spotlight
MegaElectronic is a large electronics store. After analyzing their search data, MegaElectronic notices that many of their customers perform a product search using a product’s part number. In such cases, MegaElectronic wants to redirect to the web page that is associated with the product, if the customer searched for it directly and only a single product was found.
To achieve this result, you can use a single rule with three conditions. The first condition checks that the returned search has only a single result. The second condition ensures that the query term matches MegaElectronic’s part number format for the results that they want to cause the redirect. The third condition ensures that the customer did not use any facets to drill down to one result, given that the part number might be a partial part number and return more than one result. The action redirects to a field within the result.
On condition:
targeted template's primary results equal 1
query q matches regular expression ^\D\D\D-\d+
no facet selected ^\D\D\D-\d+
Perform the following actions:
redirect to result field "loc" in template *targeted for search *primary
You can use Post-Search Rules to select which presentation template is used to display the search results based on the incoming query.
To add a new post-search rule
On the product menu, click Rules > Post-Search Rules.
On the Post-Search Rules page, click Add New Rule.
In the Name field, type the name of the new query cleaning rule.
On the Add Post-Search Rule page, use the drop-down lists and text fields to build out your query.
Option |
Description |
---|---|
Cookie |
An HTTP cookie. Cookie names and values must be Uniform Resource Identifier encoded. |
Custom Variable |
A user-defined variable. You can add, delete, or set an unlimited number of custom variables. You can reference any custom variables that you defined in Query Cleaning and in Pre-Search Rules modules, within Post-Search Rules. |
System Variable |
Read-only variables set by the internal system that you can check. The following system variables are supported:
|
System Variable |
Read-only variables that you can use in conditions to determine the current state. |
Template's Search Facet |
A facet that is local to a named search associated with a presentation template. A facet is essentially special CGI parameters used to indicate which value within a facet a customer has selected. |
Template's Search Parameter |
A CGI parameter that is local to a named search associated with a presentation template. |
Template's Backend Parameter |
Incoming query parameters eventually get translated into backend parameters that are used to perform the search. See Backend search CGI parameters . Backend parameters do not show up on navigation elements. As a result, you can hide any additional parameters that you want to apply to a search from your customers. The parameter is local to a specific search within a presentation template. Actions on backend parameters are late-binding; that is, they are applied just before the search is sent. |
Targeted Template |
A special instance of a system-defined custom variable that cannot be deleted. This variable contains the current targeted presentation template. |
Rank |
Lets you specify which ranking rule to use in the search. This option only appears when you have defined ranking fields and ranking rules. |
Last Rule |
When checked, the post-search processing module does not perform any additional rules after the action of the matching rule. This action is useful for when you have set actions that cause a later rule to match but you do not want the later rule to run. |
Suspend |
Turns off the running of the rule but does not delete the rule. |
Click Add.
(Optional) Do one of the following:
Click History to revert any changes that you have made.
Click Live.
Click Push Live.
You can edit existing post-search rules that you have added to the Post-Search Rules page.
To edit a post-search rule
On the product menu, click Rules > Pre-Search Rules.
On the Post-Search Rules page, under the Actions column of the table, click Edit for the associated rule that you want to edit.
On the Edit Post-Search Rule page, use the drop-down lists and text fields to build out your query.
See the table of options under Adding a new post-search rule.
Click Save Changes.
(Optional) Do one of the following:
Click History to revert any changes that you have made.
Click Live.
Click Push Live.
You can delete post-search rules that you no longer need or use.
When you delete a rule, the order that the remaining rules run is adjusted automatically to account for the deletion.
To delete a post-search rule
On the product menu, click Rules > Post-Search Rules.
On the Post-Search Rules page, under the Actions column of the table, click Delete for the associated rule that you want to delete.
In the Confirmation dialog box, click OK.
(Optional) Do one of the following:
Click History to revert any changes that you have made.
Click Live.
Click Push Live.
You can reorder post-search rules to change the order in which they run on presentation templates.
Post-search rules run in the order that they were defined. The higher a rule’s order number, the later it runs in the process, trumping earlier rules. You reorder rules by entering a new number in the Order column of the table on the Post-Search Rules page. You can also use drag-and-drop on rules to change their run order.
To change the order that post-search rules run
On the product menu, click Rules > Post-Search Rules.
On the Post-Search Rules page, do one of the following:
Click Save Changes.
(Optional) Do one of the following:
Click History to revert any changes that you have made.
Click Live.
Click Push Live.