Query rule patterns consist of a sequence of elements and operators that are matched against the end-user’s search input. A text pattern consists of one or more elements; all elements must match in order for the whole pattern to match. A single element might match multiple index terms. When a match is found, the query rule actions modify the query behavior as specified in the rule.
Rule syntax is described in the table following this procedure.
To add a new query rule:
On the Search Workbench tab, select Query Rules from the Show menu.
In the Query Rules menu, go to Query Rule Sets > Your Rule Set > Your Rule Group.
Under Child Query Rules, click Add New Rule.
On the Pattern tab, enter the following:
The pattern itself.
Weight given to the pattern (default value is 100).
Group name, if desired; this allows you to activate or deactivate rules together.
The language of the pattern.
On the Actions tab, enter the following:
The action to be performed on the pattern.
Note: At least one action must be defined for each rule.
The language of the action.
The Language value controls what language is used for references to literal terms. Since the rule’s terms are only in one language, then they can only match if that language is also the query language. The exception to this is the
%term%
syntax, which will expand this term using any available cross-language expansions. Specifying the language value on a rule expresses the concept of “specific” language rules.Click Create to add this rule and return to the rule group, or Create & Add Another to add more patterns to the rule.
The table that follows describes the pattern elements and their syntax.
Pattern Element | Description |
---|---|
Simple index term element | The most basic pattern element is a simple index term, expressed as just the alphabetic string of the term, such as Example: Simple element |
Literal term element | To match an exact form of a term, enclose the alphabetic string of the form in double-quotes. This restricts the index term to matching the morphological information in the element. Example: The element |
Number term element | An element consisting of numbers is treated in the same was as a simple index term element. Typically, numbers don’t have morphological forms, except some plurals (such as 1980s) and ordinals (10th). To restrict the number element to match only the literal number, enclose the element in double-quotes, just like the literal term element. |
Expanded index term element | The simple index term element only matches morphological forms of itself. To expand the pattern to match any of the term’s thesaurus entries as well, enclose it in percent characters, such as When this syntax is used, the element matches any form of the term, plus any of the terms listed in its thesaurus entries. The element can be limited to thesaurus entries for a particular part of speech by appending it after the term. Examples: |
Wild card elements | Text patterns can contain wild cards. The results are similar to the expanded term element, except the expansion does not use the thesaurus. For example, the element |
Negative elements | Elements marked with the negative operator (!), such as Note: You cannot create a rule with only negative elements; for instance, you cannot specify “!shoes” as the pattern, since that would require Search to match on every other imaginable search term. |
Element sequences | A text pattern can consist of more than one element. Multiple elements that appear in the same pattern with intervening white space create a Boolean AND operator, such as sell stock. This pattern matches the elements in any order (either sell stock or stock sell) but requires them to be adjacent. |
Element order operator | To stipulate that one element must precede another in order for the pattern to match a statement, use the order operator (-) between the elements, such as |
Element distance operator | By default, two adjacent elements in a pattern are required to be adjacent in the matching statement. To adjust the distance that is allowed to appear between the elements, a period is used. This operator can take the following forms: . – a single period means one intervening term is allowed between the elements. .. – two periods mean two intervening term are allowed between the elements. … – three periods mean three intervening terms are allowed between the elements; same as .3; and so on, with more periods. .N – a single period followed by an integer means N intervening terms are allowed. .* -- a single period followed by an asterisk means infinite intervening terms are allowed. Note that white-space is required before and after any of these operators. |
Element order and distance operators | Text patterns can combine the order and distance operators to require that the elements must be in order and within the denoted distance. The operators can be added in either order, but both require preceding white space. Example: |
Element macros | Users can define macros that expand to an |
Query rules have actions that execute and modify the query behavior in some way. The actions are expressed in a command argument notation action,arg1,arg2,…,argN. Most actions refer to patterns, but a few act independently. The action types and their argument structures are described in the table that follows.
Action | Syntax | Argument Description | Example |
---|---|---|---|
Add additional terms to the query |
| term—Strings representing any index term. If the term is a morphological form, it is analyzed and converted to its index term. The action makes no reference to the pattern. | The following action adds the term help to the query terms:
|
Remove terms from the query |
| refterm—References to index term elements in the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action deletes the term system from a query that matches the given pattern:
|
Change the weight of terms in the query |
| value—A non-negative integer ranging from 0 to 100. refterm—Reference to index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action sets the weight of the term floppy to 100 in a query that matches the given pattern:
|
Add additional negative (!) terms to the query |
| term–Strings representing any index term. If the term is a morphological form, it is analyzed and converted to its index term. | The following action adds a negated term !fee to a query term vector:
|
Add additional required (+) terms to the query |
| term–Strings representing any index term. If the term is a morphological form, it is analyzed and converted to its index term. | The following action adds a required term +procedure to the query term vector:
|
Add additional negative (!!) terms to the query |
| term–Strings representing any index term. If the term is a morphological form, it is analyzed and converted to its index term. | The following action adds a negated term !!sony to the query term vector:
|
Add additional required (++) terms to the query |
| term–Strings representing any index term. If the term is a morphological form, it is analyzed and converted to its index term. | The following action adds a required term ++dell to the query term vector:
|
Make a query term required (+) in the statement results |
| refterm–A reference to index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the term floppy required in queries that match the given pattern:
|
Make a query term required (++) in the index item (document) results |
| refterm—Index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the term insurance required in document in queries that match the given pattern:
|
Make a query term have no term expansions |
| refterm–A reference to index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action removes the expansions for the term charge in queries that match the given pattern:
|
Change the expansion of a query |
| refterm–A reference to a simple index term element of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. term–Forms of any index term, reduced by morphological analysis. | The following action changes the expansion of the term book in queries that match the given pattern:
|
Add to the expansion of a query term |
| refterm–A reference to a simple index term element of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. term–Forms of any index term, reduced by morphological analysis. | The following action adds the expansion account to the term book in queries that match the following pattern:
|
Remove terms from the expansion of a query term |
| refterm–A reference to a simple index term element of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. term–Forms of any index term, reduced by morphological analysis. | The following action deletes the expansion human from the term person for queries that match the given pattern:
|
Make a query term match literally |
| refterm–A reference to index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the term plan double-quoted in queries that match the given pattern:
|
Make a sequence of query terms match literally (in double-quotes) |
| refterm—A reference to sequential index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the phrase savings plan double-quoted in queries that match the given pattern:
|
Make a sequence of query terms match in order and within an adjacency distance constraint |
| adjacency–The distance permitted between the terms of the sequence, where 0 means adjacent, 1 means one intervening term, and so on. refterm–A reference to sequential index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the sequence savings plan with adjacency 1 in queries that match the given pattern:
|
Make a sequence of query terms match within an adjacency distance constraint |
| adjacency–The distance permitted between the terms of the sequence, where 0 means adjacent, 1 means one intervening term, and so on. refterm—A reference to sequential index term elements of the query patterns, using the same string as in the pattern. A refterm argument that can not be found as an element is ignored. | The following action makes the terms savings plan have adjacency 2 in queries that match the given pattern:
|
Add a document set constraint to the current query constraints |
| docset–A valid document set. A docset argument that is invalid is ignored. If more than one docset argument is provided, a Boolean OR of the document set constraints is added. If the current query already has constraints, these added constraints are joined with a Boolean AND. | The following action adds an OR of document sets as a constraint for the current query:
|
Add a document URL constraint to the current query constraints |
| url—A reference to a valid index item. A url argument that is invalid is ignored. If more than one url argument is provided, a Boolean OR of the document constraints is added. If the current query already has constraints, these added constraints are joined with a Boolean AND. | The following action adds an OR of two URLs as a constraint for the current query: doc,http://www.mycorp.com/home.html,http://www.mycorp.com/help.html |
Add a meta-data property constraint to the current query constraints |
| type–A valid property type ( name—A valid property of the given type within the indexed content. val—Values of the given property. If more than one val argument is provided, a Boolean OR of the property constraints is added. If the current query already has constraints, these added constraints are joined with a Boolean AND. | The following action adds an
|
Add a document set preference to the current query |
| weight—A positive integer between 1 and 100; represents a preference for results that are within the document set arguments. The preference values effect the relevancy computation. docset—A reference to a valid document set. A docset argument that is invalid is ignored. If more than one docset argument is provided, a Boolean OR of the document set preferences is added. | The following action adds a document set preference of 50 for one document set, essentially giving it 50 bonus points in the relevancy computation:
|
Add a document URL preference to the current query |
| weight—A positive integer between 1 and 100; represents a preference for results that are within the document set arguments. The preference values effect the relevancy computation. url—A reference to a valid index item. A url argument that is invalid is ignored. If more than one url argument is provided, a Boolean OR of the document preferences is added. | The following action adds a document preference of 60 for 1 document:
|
Add a meta-data property preference to the current query |
| weight—A positive integer between 1 and 100; represents a preference for results that are within the document set arguments. The preference values effect the relevancy computation. type–A valid property type ( name—Must be a valid property of the given type within the indexed content. val—Values of the given property. If more than one val argument is provided, a Boolean OR of the property preferences is added | The following action adds an
|
Add a statement feature constraint (i.e. for fielded search) to the current query |
| field–Must be valid text fields. A text field that is invalid is ignored. If more than one field argument is provided, a Boolean OR of the feature constraint is added. | The following action adds a statement feature constraint of 2 fields:
|
Add an arbitrary action result that will be included in the response to the current query |
| arg–Arbitrary strings which are simply returned back with the response in a comma-delimited list. |
|