Overview
OpenSearch offers the real-time top search feature to enhance the user search experience and meet your business requirements. This feature trains and updates top search lists in real time. It also supports tagging items as 'viral', 'new', or 'hot' to keep your top search list relevant and improve search guidance.
Procedure
-
Log on to the OpenSearch console. In the left-side navigation pane, choose OpenSearch Industry Algorithm Edition > Search Algorithm Center > Search Guidance > Top Searches and Hints. Select the target OpenSearch application and then click Create.
-
Enter a model name. For model type, select real-time top search model. Configure the source of hot queries, source period, and training cycle for the model training data. You can also set a filter condition as needed. Then, click OK.
-
After the real-time top search model is created, you can click Finish or click Train Model to begin training.
-
Click Train Model. In the confirmation dialog box that appears, click OK to start training or click Cancel.
-
You are then redirected to the model details page, where you can view the model's Basic Information, Configuration Information, data verification, and training history. After you click OK, the Latest Version Status on the model details page displays Training with a progress percentage. The page also contains a data verification section (which shows data completeness and level) and training history records.
-
When the Model Status changes to available and the Latest Version Status changes to trained and ready, the model training is complete. You can then click preview effects to view the results.
-
In the preview effects window, you can view the top search ranking, hot queries, and tag: The preview effects window displays a table of top search results that includes columns for top search ranking, hot queries, and tag. Supported tags include New, Hot, and Viral. The table supports pagination.
Note:
-
New: A query that appears in the current results but not in the previous ones.
-
Hot: A query that is popular in both the current and previous results.
-
Viral: A popular query whose ranking has risen sharply from the previous training period.
-
To manually influence the real-time top search results, you can configure a blacklist and whitelist.
-
You can create a maximum of five real-time top search models per OpenSearch instance.
-
The training of real-time top search models is billed separately. For more information, see OpenSearch Industry Algorithm Edition billing overview.
-
The real-time top search feature is available only for OpenSearch Industry Algorithm Edition instances that use an exclusive cluster or have higher specifications.
-
You must include the
raw_queryparameter in search processing. For best results, upload user behavior data, such as impression and click data, by using Data Collection 2.0.
API and SDK
For API reference, see Top Searches and Hints.
Java SDK 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 your OpenSearch instance";//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 an OpenSearchClient instance.
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 search queries to return. Valid values: 0 to 50. (The range for standard top searches is 0 to 30.)
try {
String response = client.call(requestPath, params, OpenSearchClient.METHOD_GET);
System.out.println(JSON.toJSONString(response));
} catch (OpenSearchClientException e) {
e.printStackTrace();
}
}
}