This topic describes how to run search tests in the console.
Overview
After you upload your data, you can start testing your search. The console provides a built-in Search Test page where you can configure query clauses and parameters to run tests. You can configure client-side query requests based on your requirements. For more information, see API Overview and SDK Introduction. On the Search Test page, for example, you can click the "+" button next to a clause or parameter, select the required clause or parameter from the drop-down list, enter a value for the clause or parameter, and then click Search to test the search results.
Procedure
-
Log on to the OpenSearch console, switch to OpenSearch High-performance Search Edition, and in the left-side navigation pane, go to Feature Extensions > Search Test.
-
Native query.
For example, enter id:'1' in the query clause and set the config clause to start:0,hit:10,format:fulljson. After you click Search, the results show one matching record, a time consumption of 26.737 ms, and an LCU consumption of 0.294.
Clause descriptions: query clause, filter clause, sort clause, distinct clause, aggregate clause, kvpair clause, and config clause.
Parameter descriptions: For details about query parameters, see Search processing.
-
SQL query.
For more information about SQL syntax, see SQL Support.
For more information about configuring dynamic parameters (dynamic_params), see Dynamic parameters.
The SQL query interface provides an input box where you can enter an SQL statement, such as SELECT * FROM table_name WHERE id='1', and configure dynamic parameters (dynamic_params). After you click Search, the page displays the query results and time consumption information at the bottom.
Page features
Native query
-
Add a query clause.
Click the + button in the parameter row and select a clause type from the drop-down menu. Options include filter clause, sort clause, distinct clause, aggregate clause, kvpair clause, and config clause.
-
Add a query parameter.
Click the + button in the Parameters row and select a parameter from the drop-down menu. Options include: display fields (fetch_fields), query analysis (qp), query strategy (search_strategy), first-rank expression (first_rank_name), and second-rank expression (second_rank_name).
-
Display query URL: Displays the encoded query string.
In this example, the query clause is set to default:'1' and the config clause is set to start:0,hit:10,format:fulljson. The page displays the corresponding encoded query URL at the bottom.
-
Display sort details: Use this feature to view the scoring details of sort expressions.
The sort details section has two stages: FirstRank and SecondRank. It lists each expression, such as static_bm25(), normalize(sold_num), query_match_ratio, and field_match_ratio, and its result value. It also displays the overall score of the final sort formula, such as 0.6*static_bm25()+0.4*normalize(sold_num).
-
Source code mode: When you set the format parameter in the config clause to fulljson and include an aggregate clause, you can enable source code mode to view the facet statistics in the aggregate clause.
For example, set the config clause to start:0,hit:0,format:fulljson and the aggregate clause to group_key:is_promotion,agg_fun:sum(is_promotion). After you enable source code mode, the facet array in the JSON response returns an aggregation statistics object. Each element in its items array contains the sum, value, and key fields, where sum is the aggregated value, value is the statistical value, and key is the group key name.
SQL query
-
Source code mode: You can enable source code mode to retrieve query results in formats such as JSON.
After you enable source code mode in the upper-right corner of the query results page, the JSON response includes fields such as searchtime (query time consumption), compute_cost (compute cost), num (number of results), and items (data list).
When you use a Cava sort function in a business sort strategy, the sort details do not display the Cava sorting algorithm. You must output the algorithm's trace in the Cava script. For more information, see OpsDoc.