Product docs
- Getting started
- Platform and account
- Products
- Product Overview
- Tengence Search
- Product Overview
- Use cases: which businesses Tengence Search fits
- Getting started
- Search Setup: App, Dataset, Index, First Query
- OpenSearch Spring Boot Starter Integration
- Elasticsearch Spring Boot Starter Integration
- Guides
- Index Concepts and Configuration Guide
- Index Schema Reference
- Search Ranking and Weighting Configuration
- Ranking Factors and Functions Reference
- Search Suggestions and Intervention Rules
- Developer reference
- Search API Reference
- Search API Integration and Examples
- Search Widget Integration
- Operations and support
- Search Operations and Monitoring
- Search Troubleshooting
- Query Rules and Query Intervention
- Search Log Collection Policy
- Query Understanding Configuration
- Tengence GEO
- Tengence Recommendation
- Tengence Insight
- Data Integration
- Integration and API
- Solutions
- Concepts and metrics
Query Rules and Query Intervention
Configure rewrite, replace, append, remove, reject and redirect rules for specific queries, including match types, normalization, priority and activation.
Query rules process the query before search runs: they can rewrite it, remove parts of it, reject it, or send the user to another page. They change the query, not the results. Which documents match and how they are ordered is still controlled by the index and ranking configuration.
It helps to separate three related settings:
- Query understanding handles general processing such as tokenization, stop words, traditional-to-simplified conversion, spell correction and synonym expansion. It applies to every query.
- Query rules apply a forced action to a specific query. They take precedence and are suited to blocking sensitive terms, correcting typos and sending brand terms to a campaign page.
- Query suggestions work on candidate words. They do not change candidate text directly, but suggestion requests also pass through query understanding: a rejected or redirected query returns no suggestions.

What a rule contains
A rule is an if-then statement: if the query matches a condition, run an action, either permanently or for a limited period.
Each rule has four parts:
- Match type: exact match, contains substring, prefix match, suffix match or regular expression.
- Match value: the query text or expression to match.
- Action type: rewrite all, partial replace, append content, remove part, reject query or redirect.
- Action value: the new query, appended text, rejection reason or redirect URL. Some actions do not need a value.
Open Intervention → Query Intervention and click Add query rule. The drawer lets you add several rules at once and save them together with Confirm.

Queries are normalized before matching
Rules do not match the raw input. They match the query after query understanding has normalized it. Normalization:
- trims leading and trailing spaces;
- converts full-width characters to half-width;
- converts Traditional Chinese to Simplified Chinese;
- lowercases the text.
Configure match values in that normalized form: Simplified Chinese, half-width and lowercase. A user can type COFFEE TABLE or a Traditional Chinese variant and still hit the rule, but a match value written in full-width or Traditional Chinese may never match.
Match types
| Match type | Meaning | Example |
|---|---|---|
| Exact match | The normalized query equals the match value | coffee table matches only coffee table |
| Contains substring | The query contains the match value | coffee matches coffee table and buy coffee |
| Prefix match | The query starts with the match value | cof matches coffee table |
| Suffix match | The query ends with the match value | table matches coffee table |
| Regular expression | Java regex, matched against the whole query | coffee.* matches queries starting with coffee |
The first four match types are case-insensitive. A regular expression must match the entire query, not a substring: coffee will not match coffee table; use coffee.*. Regex matching is case-sensitive by default, so add (?i) when case should be ignored. An invalid regex does not raise an error; it simply never matches.
Action types
| Action type | Action value | Effect | Typical use |
|---|---|---|---|
| Rewrite all | Required, new query | Replaces the whole query | Typo correction, renaming an old product |
| Partial replace | Required, replacement text | Replaces the matched part of the query | Replacing one term |
| Append content | Required, appended text | Adds text to the end of the query | Adding a category or modifier |
| Remove part | Optional | Removes the matched part and trims the result | Removing free-shipping or promo wording |
| Reject query | Optional, rejection reason | Marks the query as rejected and returns a reason | Sensitive terms, dangerous goods, meaningless input |
| Redirect | Required, redirect URL | Returns a redirect URL without rewriting the query | Brand terms, campaign pages, help pages |
Details that commonly cause problems:
- Append content does not add a space. Query
sofaplus valueliving roomproducessofaliving room. To getsofa living room, start the value with a space:living room. - Partial replace and remove part depend on the matched text. Exact match and contains substring take the match value; prefix and suffix take the corresponding part of the query; regex takes the actual match. If no part can be extracted, the action does nothing.
- Reject query does not rewrite the query. It sets a rejected marker and returns the reason. If the reason is empty, a system default is used. The main search endpoint still returns results for the original query, so a business frontend or gateway that needs to block results must consume the query-understanding result and handle the rejected marker. The rule alone does not empty the result list.
- Redirect only returns a URL. It does not use the URL as the search query and does not navigate the browser. The business frontend must read
redirectUrland perform the navigation. - Rewrite all and partial replace change the query used for retrieval. The rewritten text is normalized again, so uppercase and full-width characters are not preserved.
How multiple matches are resolved
Only one rule runs for a query, even when several rules match.
Rules are matched in reverse update-time order: the most recently saved rule matches first, and the pipeline returns immediately without evaluating later rules. Rules are not chained; the output of one rule never becomes the input of another.
The practical way to change priority is to edit and save the rule you want. Saving refreshes its update time and moves it to the front of the matching order.
Use Debug on the page to see which rules matched the current query. Debug returns up to five matches and marks the one that was actually applied. Production traffic only applies the final winning rule.
Effective period, disabling and deletion
- Permanent: the rule stays active until it is disabled or deleted.
- Limited period: set a start and end time. The end time must be later than the start time.
- Enabled switch: turning it off stops matching immediately, with no redeploy.
- Delete: removes the rule from the list and cache immediately.
Note: the start and end time are currently used for labeling, sorting and filtering rules in the list. They do not automatically disable a rule when the end time passes. Disable or delete limited-time rules manually when a campaign ends instead of relying on the time window.
Within one app, rules with the same match type, match value and action type cannot be duplicated, even if their action values differ. If you need two different rewrites, use a different match type or a different action type.
Four common configurations
| Goal | Match type | Match value | Action type | Action value |
|---|---|---|---|---|
| Block a sensitive query | Exact match | dangerous goods |
Reject query | This query is not supported |
| Correct a typo | Exact match | coffe table |
Rewrite all | coffee table |
| Remove a promo suffix | Suffix match | free shipping |
Remove part | Leave empty |
| Send a brand term to a page | Exact match | aurora |
Redirect | https://www.tengence.com/en/ |
Three configuration cautions:
- Match values must use the normalized form. You do not need separate rules for uppercase, mixed case or full-width input; normalization handles those.
- Do not make prefixes or suffixes too short. A prefix of
amatches every query that starts with a and will almost certainly over-trigger. - Reject and redirect are strong actions. Use Debug to confirm that only the intended query matches before enabling them.
Pre-launch checklist
- Confirm the rule is created in the correct app. Rules are isolated by app and never apply across apps.
- Confirm the match value uses the normalized form: Simplified Chinese, half-width and lowercase.
- Confirm the match type. Use exact match for the whole query and contains substring for part of it; do not use exact match against a longer query.
- Confirm required action values are filled. Rewrite all, partial replace, append content and redirect require a value; a redirect must be a complete, reachable URL.
- Confirm the rule is enabled. Disabled and deleted rules never run.
- Use Debug to test the target query, a similar query and a query that should not match. Check for over-triggering.
- Disable or delete limited-time rules when the campaign ends so stale rules do not affect later operations.
Common questions
The rule is saved but does not take effect
Check the app and the enabled switch first, then use Debug to see whether the query matches. A match value that is not normalized, an invalid regex or the wrong match type will all prevent a match. Also confirm the query is not empty: empty queries do not run query rules.
I changed a rule but production still behaves the same
Saving a rule refreshes the cache, so new requests use it immediately; requests already in flight are unaffected. If you changed the match value or action type with Edit, confirm the save succeeded and re-check with Debug.
Several rules match, but the wrong one runs
Only the most recently saved rule runs. Open the rule you want and save it again to refresh its update time, then re-test. Do not rely on creation order for priority.
What does a caller receive after a reject rule
Query understanding returns a rejected marker and the rejection reason. The main search endpoint does not currently return an empty result set just because a reject rule exists. A business frontend or gateway that needs to block the display must consume the query-understanding result and handle the rejected marker; the rule alone is not an enforcement boundary. Write a clear business reason so it can be shown or logged.
A redirect rule does not navigate the page
Query rules only produce a redirect URL; they never navigate the browser. Confirm the action value is a complete URL with https://, and confirm the action type is Redirect, not Rewrite all. The frontend must read redirectUrl and navigate.
Partial replace produces awkward text
Partial replace only swaps the matched fragment and does not adjust the surrounding sentence. Use Rewrite all for a full rewrite, or Remove part to drop an unwanted modifier.
Related documentation
- Search Suggestions and Intervention Rules: candidate-word intervention for autocomplete, popular searches and placeholder hints.
- Search Ranking and Boost Configuration: result ordering, field weights and reranking.
- Search Operations and Monitoring: traffic, zero-result rate and top queries after launch.
- Search Troubleshooting: what to check when a query returns nothing or results look wrong.