Show Menu
TOPICS×

About Pre-Search Rules

Use Pre-Search Rules to analyze the incoming query and determine which presentation template to use. Pre-Search Rules are executed in sequence for every query. To alter the order of your rules you can use drag-and-drop. The actual order does not change until you save it.

Using Pre-Search Rules

Pre-Search Rules are typically used to select which presentation template displays the results based on the incoming query. More advanced features can be used to alter the query that is used for a search that is being done for a presentation template. You can add, delete, or change the value of query parameters as needed. For every incoming query a pre-search-processing module examines the pre-search rules to determine if the query is modified and what presentation template is used. Each Pre-Search Rule consists of two main elements: the rule's actions and 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 is matched, all the associated actions are performed.
In the Pre-Search Processing module all defined templates and their associated named searches are instantiated where each search is given a local copy of the cgi parameters. As a result, you can customize a search by adding, deleting, or altering one of the cgi parameters that search uses without altering any other named search the template uses or affecting any of the other templates. As a result, if you have a presentation template that displays more than one result set, you can customize each search individually. If you want to perform changes on the global CGI parameters before they are copied to each search for each template, use the Query Cleaning module.

Pre-Search Rule Conditions

Conditions are optional. If you choose to have actions specified for every query then the actions are always taken. It is considered best practice for your first rule to run for every query, where it selects your default presentation template. This way you can be assured that, regardless what the incoming query is, you have selected a worst-case scenario presentation template to use. Conditions can be based on any CGI query parameter, cookie, or custom variable that a previous rule has set or a system variable.

Pre-Search Rule Actions

All of the actions within a Pre-Search Rule that has 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 specify which presentation template to use when the query matches the Pre-Search Rule's conditions. Then set the targeted template to the name of the presentation template. More complicated actions can be used to change the search that is being used for a given template via performing an operation on a template's search parameter. When performing an operation on a template's search parameter, you specify a presentation template and search.

Generic 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. With these values, you can build rules based on the current targeted template's primary search. These constructs allow for building generic rules where you do not have to worry about what the current targeted template or primary search are called. Obviously, a previous Pre-Search Rule defines what the current targeted template is. Otherwise, an initial presentation template is selected for you, which produces undesired results.

Examples

Set the default template to guided.tmpl, when the user passes in a cgi parameter called lang, set to a known language, use that language's template.
    On condition: 
      Every Query 
    Perform the following actions: 
      Set targeted template to guided 
 
    On condition: 
      Query lang matches regular expression fr 
    Perform the following actions: 
      Set targeted template to guided_french 
 
    On condition: 
      Query lang matches regular expression de 
    Perform the following actions: 
      Set targeted template to guided_german

Best Practices

  • The first rule selects a default template for every query.
  • Data mining of the query is done within query cleaning rules. You can reference them in the pre-search processing.
  • Add any new custom variables that you introduced in Pre-Search Rules to a pre-search rule that is run for every query before any other Pre-Search Rules reference them.

Adding a new pre-search rule

You can use Pre-Search Rules to select which presentation template is used to display the search results based on the incoming query.
To add a new pre-search rule
  1. On the product menu, click Rules > Pre-Search Rules .
  2. On the Pre-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 Pre-Search Rule page, use the drop-down lists and text fields to build out your query.
    Option
    Description
    Cookie
    An HTTP cookie. Cookies name and values must be Uniform Resource Identifier encoded.
    Custom Variable
    A user-defined variable. Add, delete, or set an unlimited amount of user-defined variables.
    You can reference any variables that you defined in the Query Cleaning module within the Pre-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 uri without the query string.
    • args
      The entire query string.
    • environment
      "Stage" or "live" depending on whether the incoming query was sent to your staged or live environment.
    • referrer
      The URL that the customer came from.
    Facet
    Special CGI Parameters in the global collection that are associated with a particular facet. All CGI parameters are copied to each named search within a template after Query Cleaning.
    Query Parameter
    CGI Parameter in the global collection. These parameters are copied to each named search within a template after Query Cleaning.
    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. You can read or set this variable by specifying the custom variable "targeted_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.
    Store
    The search engine automatically detects what store the customer is in based on the host name or the gs_store query parameter, with the latter having precedence. You can create conditions off of the store. In query cleaning only, you can also use an action to over-ride the current store.
    Last Rule
    When checked, the pre-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 pre-search rule

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

Deleting a pre-search rule

You can delete pre-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 pre-search rule
  1. On the product menu, click Rules > Pre-Search Rules .
  2. On the Pre-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 pre-search rules run

You can reorder pre-search rules to change the order in which they run on presentation templates.
Pre-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 Pre-Search Rules page. You can also use drag-and-drop on rules to change their run order.
To change the order that pre-search rules run
  1. On the product menu, click Rules > Pre-Search Rules .
  2. On the Pre-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: