After you deploy a cluster, you can start exploring its search features. OpenSearch Retrieval Engine Edition provides a built-in query test feature in its console to help you test queries. You can configure various search clauses to customize and test queries based on your search requirements.
Procedure
-
In the OpenSearch Retrieval Engine Edition console, go to the Instances page. In the list of instances, find your instance and click Query Test in the Actions column.
-
On the Query Test page, select a query type (SQL query, Havenask Query, or REST API Query). You can add clauses as needed. After you configure the query, click Search to view the results.
Havenask query
Select Havenask Query from the drop-down list. The corresponding input fields for the query string and clauses appear. The query statement is required for a Havenask Query. The config and cluster statements within the clauses are also required and added by default. You can add other clauses as needed.
Click the + button to the right of the clauses section to open a drop-down menu. From this menu, you can select a clause to add, including kvpairs clause, filter clause, pkfilter clause, aggregate clause, attribute clause, virtual_attribute clause, distinct clause, sort clause, and layer clause.
Havenask query results:
For example, enter id:'100532569311552725' in the query field. The config clause defaults to start:0,hit:10,format:json, and the cluster clause defaults to general. After you click Search, the page shows the full query statement and result statistics, such as the number of results and the time taken. It also lists the field values for matching documents, such as id, fb_datetime, fb_boolean, and fb_string. In the upper-right corner, use the Displayed Fields input box to control the number of fields returned and toggle the Show URL switch to view the request URL.
SQL query
Select SQL query from the drop-down list. Enter a query statement in the query field, which is required, and then click Search.
You can add a kvpair clause as needed.
In the sql= input box, enter a query statement, such as select * from index_a where id = 7370577090061071286.
SQL query results:
After you run the query, the results area shows the complete query string at the top, such as query=select * from index_a &&kvpair=format:full_json. Below this, the execution time (USE_TIME) and the row count (ROW_COUNT) are shown. The retrieved data is shown in the TABLE INFO table. In the upper-right corner, use the Displayed Fields input box to control the number of columns displayed, such as setting it to 10. Toggle the Show URL switch to view the full request URL, and the Raw switch to view the raw response content.
You cannot use a SELECT statement to retrieve data from fields with the DATE, TIME, or TIMESTAMP data type.
REST API query
After you select REST API Query from the drop-down list, an Index Table drop-down list appears. The left pane is for entering JSON-formatted queries, and the right pane displays the results. Select an index table from the Index Table drop-down list, enter the query in the JSON input area on the left, and click Search.
Enter the REST API query string and click Search. The results appear on the right:
In this example, the index_odps index table is selected. The query returns one matching record in XML format. The record includes fields such as id, name, age, price, crate_data, and get_marry, along with their corresponding values.
{
"query": "index_id:12"
}