Overview
Top searches and hints are essential features of a complete search engine. They are often displayed in prominent positions in or near the search box and provide indispensable business value.
In a search engine, top searches and hints are provided to users in the first step of the search process. Better top searches and hints facilitate search optimization by reducing the difficulties in optimizing steps such as query analysis, sorting, and operational intervention. In addition, top searches and hints can be used with operational strategies to achieve business goals.
From the perspective of users, top searches and hints can meet the following requirements:
Users who do not know what to search for want to check the recommended high-quality queries.
Users want to know what everyone is searching for.
Users want diverse queries that are recommended based on their interests. This way, these users can search for what they are interested in and explore content beyond their interests.
From the perspective of operators, top searches and hints can provide the following business value:
Operators can obtain queries that have been searched most. Hot queries indicate the interests of users. Operators can analyze hot queries to grasp the interest trend and formulate operational strategies.
Operators can use drop-down suggestions to guide the intents of users when they enter something in the search box. For users who have not entered anything, operators can use top searches and hints to recommend high-quality queries to these users.
Top searches and hints ensure that diverse queries, instead of only the hottest queries, are recommended to users. This ensures user experience and increases the chance that popular queries, but not the hottest queries, are displayed to users.
Operators can analyze the behavior of users to recommend queries based on their preferences. This improves user experience and the precision of recommendations.
The top search list in the console and the top search recommendation interface have the following differences:
The top search recommendation interface collects statistics only on queries within the past 14 days.
The top search recommendation interface collects statistics only on the queries that are performed by using the raw_query parameter. The top search list in the console collects statistics not only on the queries that are performed by using the raw_query parameter, but also on the queries that are performed by using the default index.
The top search recommendation interface filters out queries that have no search results. The top search list in the console does not filter out such queries.
Usage notes
The system trains the top search and hint models by using the queries that are labeled as raw_query in historical search requests. If the historical search requests do not contain queries that are labeled as raw_query, the models may fail to be created.
Independent query: The raw_query parameter in the training and promotion criteria is a parameter that must be included in the search request. Its value must be an independent query that has retrieval results and is not repeated.
You can create up to three top search models or hint models.
By default, the top search list displays up to 10,000 entries. You can specify the maximum number of entries in the top search list based on your business requirements. The minimum number of entries is 100.
The models rely only on statistics that are collected from search logs based on specific algorithms. Other training goals are not supported. Therefore, the models need to be created only once.
When the system receives the request for creating the models, the system immediately starts training the models.
After the models are created, the system automatically retrains the models every day, and no human intervention is needed.
After the models are created and trained, you can query the top searches and hints in a period within the past half-year. By default, the data in the past 14 days is returned.
Create a top search or hint model
Create a top search or hint model by using the API or SDK
Management and Control SDK dependencies
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-opensearch</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.0</version>
</dependency>Demo for the SDK for Java
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.opensearch.model.v20171225.*;
import com.aliyuncs.profile.DefaultProfile;
public class CreateModel {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-beijing", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
CreateModelRequest request = new CreateModelRequest();
request.setAppGroupIdentity("app_name");
// The type parameter specifies the model type. A value of hot indicates the top search model. A value of hint indicates the hint model. The modelName parameter specifies the model name. You can enter a custom name that consists of digits, letters, and underscores (_). The name cannot contain only digits and can be up to 30 characters in length.
String content = "{\"type\": \"hot\",\"name\": \"model_name\"}";
request.setHttpContent(content.getBytes(), "UTF-8", FormatType.JSON);
try {
HttpResponse response = client.doAction(request);
System.out.println(response.getHttpContentString());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}Create a top search or hint model in the OpenSearch console
1. Log on to the OpenSearch console. In the left-side navigation pane, choose Search Algorithm Center > Search Guidance. On the Search Guidance page, click Top Searches and Hints in the left-side pane. On the Top Searches and Hints page, click Create to create a top search or hint model.

2. Configure the Model Name and Filter Condition parameters, and select Top Search Model or Hint Model as Model Type. The Filter Condition parameter is optional.

Parameter | Description |
Filter Condition | Specify the filter condition for a search request. This filter condition is used to filter historical search queries. A filter condition must be in the format of [Request parameter][Conditional operator][Value]. Only the biz_type and user_id parameters are supported. The following conditional operators are supported: <, >, <=, >=, =, and !=. If you configure multiple filter conditions, separate the conditions with a comma (,). In this case, all the conditions take effect at the same time based on the AND logical operation. The OR logical operation is not supported. For example, if you specify user_id=1,biz_type=1, only search queries that meet both two conditions can be used. For more information about search request parameters, see Initiate search requests. |
3. On the Top Searches and Hints page, find the created model in the Pending Training state and click Train in the Actions column.
4. After the training is complete, preview top search or hint effects.
Preview top search effects
Preview hint effects
Usage notes
When you preview top search effects, the Preview Effects dialog box displays 10 recommended top searches that are returned per page. Up to 20 pages of recommended top searches can be displayed.
When you preview hint effects, the Preview Effects dialog box displays 1 hint that is returned per page. Up to 30 recommended hints can be displayed.
Introduction to the Top Searches and Hints page
Top search or hint model list
On the Top Searches and Hints page, you can view the following information about each model in the model list: model name, model type, creation time, model status, start time of the last training, and status of the latest version. You can perform various operations on the models in the Actions column. You can specify a model as the default model based on your business requirements. If no model name is specified in the parameters, the default model is used.

Details page of a top search or hint model
In the Basic Information section, you can view the basic information about the top search or hint model, including the creation time, model status, start time of the last training, and status of the latest version. In the Training History section, you can view the following information about each historical training record: model version, version status, training start time, and training end time. A model training may succeed or fail.
Troubleshoot a failed training
On the model details page, move the pointer over Exception Report to view the cause of the failed training, and move the pointer over View Conditions for Integrity Level Upgrade to view the conditions for integrity level upgrade.

Custom settings
Blacklist and whitelist configurations: You can configure a blacklist and whitelist for a model based on your business requirements. To configure a blacklist and whitelist, click Configure in the Configuration Information section of the model details page. For more information, see Blacklists and whitelists.

Obtain the top searches and hints by using the API or SDK
After the top search and hint features are integrated into your product, you can obtain the recommended top searches and hints by calling API operations or using the SDK. For more information about the API operations, see the API document. For more information about how to use the SDK, see the following SDK demo code.
By default, 10 top searches and 3 hints are returned. The hints can be displayed in the search box in turn.
Usage notes
No API operation is provided for you to obtain the status of a model training task. You must check whether results are available by calling an API operation or using the SDK.
After the models are created, the system automatically runs model training tasks every day. You can obtain updated top searches and hints by calling an API operation or using the SDK.
When you use the SDK to call the API operations for obtaining top searches and hints, you can set the hit parameter to 30 at most for top searches and 10 at most for hints. The hit parameter specifies the number of top searches or hints that you want to obtain.
To obtain the rankings of hotwords, call the ListStatisticLogs operation.
Traffic SDK dependencies
<dependency>
<groupId>com.aliyun.opensearch</groupId>
<artifactId>aliyun-sdk-opensearch</artifactId>
<version>3.5.0</version>
</dependency>Demo for the SDK for Java
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.aliyun.opensearch.OpenSearchClient;
import com.aliyun.opensearch.sdk.generated.OpenSearch;
import com.aliyun.opensearch.sdk.generated.commons.OpenSearchClientException;
public class Hot {
private static final String accesskey = "Your AccessKey ID";
private static final String secret = "Your AccessKey secret";
private static final String host = "The endpoint of the OpenSearch API, such as http://opensearch-cn-hangzhou.aliyuncs.com";
private static final String appName = "The name of your OpenSearch application";
private static final String HOT_API_PATH = "/apps/{app_name}/actions/hot";
public static void main(String[] args) {
OpenSearch openSearch = new OpenSearch(accesskey, secret, host);
// Create OpenSearchClient
OpenSearchClient client = new OpenSearchClient(openSearch);
String requestPath = HOT_API_PATH.replaceAll(("\\{app_name\\}"), appName);
Map<String, String> params = new HashMap<>();
params.put("model_name", "your_model_name");// Specify the model name.
params.put("hit", "20");// Specify the number of top searches that you want to obtain.
try {
String response = client.call(requestPath, params, OpenSearchClient.METHOD_GET);
System.out.println(JSON.toJSONString(response));
} catch (OpenSearchClientException e) {
e.printStackTrace();
}
}
}Model optimization
User behavioral data
The top searches and hints that are generated based on statistics collected from search logs can meet the requirements at the initial use of the top search and hint features. After the features are put into use, we recommend that you associate user behavioral data with top searches and hints. The system collects user behavioral data, including the from_request_id and user_id parameters. The user behavioral data can be used to further optimize the models. The user behavioral data has the following benefits:
You can obtain a variety of metrics, such as the page views (PVs), unique visitors (UVs), and zero-result rate of searches guided by top searches and hints. These metrics allow you to evaluate the top search and hint features and improve the features.
You can analyze the interest trend of your user group and formulate operational strategies based on the trend.
You can recommend queries in a smart way. After you mark data based on user click behavior, you can train the models for different optimization goals. By default, models are optimized based on the click rate. Then, you can recommend queries generated by the models that have strong generalization ability.
Search traffic guided by top searches and hints
When you obtain top searches or hints by calling an API operation or using the SDK, the system returns the request_id parameter that contains an ID. The ID uniquely identifies the request. When a user clicks a top search or hint in your product, the system initiates a search request based on the top search or hint. You can allow the system to configure the from_request_id parameter in the search request to the value of the request_id parameter. This way, the user click behavior is associated with top searches and hints. After the system collects statistics from search logs and user behavioral data, you can view the metrics of search traffic guided by top searches and hints in business operation reports. If the user_id parameter is configured in search requests, you can also view the UV metric of search traffic guided by top searches and hints in business operation reports.
Usage notes
A page turning request after a search is also considered as an independent PV. Therefore, the from_request_id parameter must also be configured for a page turning request that follows a search guided by a top search or hint.
For more information about the parameters of a search request, see from_request_id and user_id.
Business operation reports
View business operation reports in the OpenSearch console
Business operation report for top searches
Log on to the OpenSearch console. In the left-side navigation pane, choose Report Statistics > Top Search Report in the left-side navigation pane to view the business operation report for top searches.

Business operation report for hints
Log on to the OpenSearch console. In the left-side navigation pane, choose Report Statistics > Hint Report in the left-side navigation pane to view the business operation report for hints.

Usage notes
For more information about the metrics in the business report for top searches, see Top search report.
For more information about the metrics in the business report for hints, see Hint report.