Overview
Top searches and hints are essential features of a complete search engine. To meet your business requirements and improve search experience for you, OpenSearch provides the real-time top search feature to implement updated top searches based on the training result in real time. The top, new, and trending searches can be labeled and displayed. This updates top searches in real time and provides better search guidance for customers.
Procedure
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. Select the application from the drop-down list, and then click Create.

On the Create Top Search or Hint Modal page, configure the Model Name parameter, select Real-time Top Search Models as Model Type, and configure the Source of Hot Queries, Source Period, and Training Cycle parameters. You can set the Filter Condition parameter based on your business requirements. Click Submit

After the real-time top search model is created, click Completed or Train.

If you click Train, a message appears. Click OK.

You are redirected to the details page of the real-time top search model. You can view the basic information, configuration information, data verification, and training history of the model.

If the model status changes to Available and the latest version status changes to Trained and Ready, the model is successfully trained. You can click Preview Effects to view the training result.

On the Preview Effects page, you can view the Top Search Ranking, Hot Queries, and Tags.

Take note of the following items:
Tag description:
New: The search is not included in the previous top searches but is included in the current top searches.
Hot: The search is included in both the previous top searches and the current top searches.
Viral: Compared with the previous training cycle, the search remains popular and quickly moves up in the ranking in the current training cycle.
If you want to intervene in the real-time top search results, you can add the blacklist and whitelist.
You can use a single OpenSearch instance to create up to five real-time top search models.
You are separately charged for the training of a real-time top search model. For more information, see Overview.
The real-time top search feature can be used only for OpenSearch Industry Algorithm Edition exclusive cluster applications or those with higher specifications.
You must set the raw_query parameter when you initiate search requests. We recommend that you upload user behavior data such as expose and click to OpenSearch by using the data collection feature for better search results.
Call an API operation or use an SDK to obtain real-time top searches
For more information about how to query top searches by calling an API operation, see Query top searches and hints.
SDK for Java demo
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";// Example: 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", "10");// Set the number of real-time top searches to query. Valid values: 0 to 50. Valid values for common top searches: 0 to 30.
try {
String response = client.call(requestPath, params, OpenSearchClient.METHOD_GET);
System.out.println(JSON.toJSONString(response));
} catch (OpenSearchClientException e) {
e.printStackTrace();
}
}
}