Show Menu
TOPICS×

About Post-Search Rules

You can use Post-Search Rules to examine the results of a search and determine how the search affects the displayed content.

Using Post-Search Rules

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.

About Post-Search Rule conditions

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.

About Post-Search Rule actions

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.

General Rules

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.

Redirects

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.

Last Rule

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.

Examples

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

Best Practices

  • Any set of rules that trigger a new round of searching should always have a conditional clause to check that this is not the last pass through the module. If you have already performed the maximum number of searches, you cannot redo any searches.
  • If you are on the last pass through the module and the results are still poor, you can switch to a "no results" template.
  • You should base changing a presentation template on the result of a search that potentially has other parameters. If you want to select a template that is based only on the incoming query, a pre-search rule is more efficient.
  • Data mining of the query is done in the Query Cleaning module. You can reference the custom variables in the post-search processing.
  • When you do redirects, always check that the customer has not selected any facets. The reason why is because it is inconvenient when a customer drills into a facet and is suddenly taken away from the search results. The customer may want to deselect the facet when they see that the single result is not want they were looking for.

Adding a new post-search rule

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
  1. On the product menu, click Rules > Post-Search Rules .
  2. On the Post-Search Rules page, click Add New Rule .
  3. In the Name field, type the name of the new query cleaning rule.
  4. 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:
    • hostname
      The name of the server host.
    • uri
      The requested Uniform Resource Identifier without the query string.
    • args
      The entire query string.
    • environment
      "Stage" or "live" depending on whether the incoming query was sent to your staged environment or your live environment.
    • referrer
      The Uniform Resource Locator that the customer came from.
    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.
    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.
  5. Click Add .
  6. (Optional) Do one of the following:

Editing a post-search rule

You can edit existing post-search rules that you have added to the Post-Search Rules page.
To edit a post-search rule
  1. On the product menu, click Rules > Pre-Search Rules .
  2. On the Post-Search Rules page, under the Actions column of the table, click Edit for the associated rule that you want to edit.
  3. 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 .
  4. Click Save Changes .
  5. (Optional) Do one of the following:

Deleting a post-search rule

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
  1. On the product menu, click Rules > Post-Search Rules .
  2. On the Post-Search Rules page, under the Actions column of the table, click Delete for the associated rule that you want to delete.
  3. In the Confirmation dialog box, click OK .
  4. (Optional) Do one of the following:

Changing the order that post-search rules run

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
  1. On the product menu, click Rules > Post-Search Rules .
  2. On the Post-Search Rules page, do one of the following:
    • Click the Order column header to sort the rules in ascending or descending order.
    • In the Order column, in the text field to the left of a pre-search rule name, type the order number that you want the rule to run.
    • Drag-and-drop a table row to the position that you want the rule to run. All the order numbers are updated to reflect the new order in which the rules run.
  3. Click Save Changes .
  4. (Optional) Do one of the following: