All Products
Search
Document Center

OpenSearch:Build an application

Last Updated:Dec 26, 2024

Prerequisites

  1. An Alibaba Cloud account is created and the real-name verification is complete.

  2. An AccessKey pair is created before you log on to the OpenSearch console by using a new Alibaba Cloud account for the first time.

    • You must specify an AccessKey pair within your Alibaba Cloud account because an OpenSearch application is created and used based on the AccessKey pair.

    • After you create an AccessKey pair within your Alibaba Cloud account, you can create an AccessKey pair for a RAM user. This way, you can access an application as the RAM user. For more information about how to grant permissions to RAM users, see Access authorization rules.

Create an application

Procedure:

  1. Purchase and create an application instance.

  2. Define an application schema, define an index schema, and then configure a data source.

  3. Run a search test.

  4. Use the search algorithm center and extended features. For example, you can configure sorting in the search algorithm center.

1. Purchase an application instance

Log on to the OpenSearch console. In the upper-left corner, move the pointer over the place where the OpenSearch edition is displayed and select OpenSearch High-performance Search Edition. In the left-side navigation pane, click Instance Management. On the page that appears, click Create Instance.

image

OpenSearch supports subscription and pay-as-you-go application instances. The following figures show the procedure for purchasing an application instance.

image

image

image

2. Configure an application instance

After the purchased application instance is initialized, it is in the Pending state. To configure the instance, click Configure in the Actions column.

imageimage

2.1 Define an application schema

You can define an application schema by using one the following methods:

Method 1: Use a template to define an application schema. You can save an application schema that you created as a template. Then, you can use the template to define a new application schema.

Method 2: Use a data file to define an application schema. You can upload a data file to the OpenSearch console. Then, OpenSearch parses the uploaded data file and generates an initial application schema. Note: The data file must be in the JSON format. After the initial application schema is generated, you must redefine specific attributes such as field types.

Method 3: Use a data source to define an application schema. You can use this method if you want to synchronize data from data sources such as ApsaraDB RDS and MaxCompute data sources. The schema of a source table can be used to generate an initial application schema. This reduces workloads on manual definition and decreases the error probability. The steps of connecting to different data sources are similar. The following figures show how to connect to an ApsaraDB RDS data source. For more information, see Configure a data source.

image

image

Method 4: Manually define an application schema.

image

2.2 Define an index schema

  • Fields used in query clauses must be configured as index fields. Fields of the FLOAT type cannot be configured as index fields. For more information, see Application schema.

  • Fields used in filter and sort clauses, and fields that are explicitly specified as attributes in functions must be configured as attribute fields.

  • You cannot configure attribute fields by using fields of text types, such as TEXT and SHORT_TEXT. You can configure attribute fields only by using fields of numeric types or non-text types, such as INT, INT_ARRAY, FLOAT, FLOAT_ARRAY, DOUBLE, DOUBLE_ARRAY, LITERAL, and LITERAL_ARRAY.

image

2.3 Configure a data source

Connect to a data source. Then, select one or more tables from the connected data source and click the rightwards arrow (>>).

14

Click OK. Then, you can configure field mappings.

15

When you configure field mappings, you can set a plug-in for data processing. For more information about how to use a plug-in for data processing, see Data processing plug-ins.

16

Note

For more information about real-time data synchronization, see Configure DTS real-time synchronization.

2.4 Complete the configuration

17

3. Run a search test

After data is uploaded, you can start to search for data. The OpenSearch console provides the Search Test feature for you to run search tests. You can configure clauses and parameters to search for data based on your business requirements. The following procedure shows how to use the Search Test feature. For more information about other search methods, see API overview and SDK overview. To run a search test on the Search Test page, move the pointer over the Plus icon next to Clauses or Parameters, select a clause or parameter that you want to use, enter the specified clause or parameter, and then click Search.

Procedure:

1. Go to the OpenSearch console. In the upper-left corner, move the pointer over the place where the OpenSearch edition is displayed and select OpenSearch High-performance Search Edition. In the left-side navigation pane, choose Feature Extensions > Search Test. On the Search Test page, specify a query clause for the query parameter. This parameter is required.

image

2. Add more clauses or parameters as required.

19

19

Clauses description

query clause

filter clause

sort clause

distinct clause

aggregate clause

kvpairs clause

config clause

Parameter description

Displayed Field - fetch_fields: the fields to be displayed. Separate multiple fields with semicolons (;).

Query analysis - qp: the name of the query analyzer.

Rough Sort Expression - first_rank_name: the name of a rough sort.

Fine Sort Expression - second_rank_name: the name of a fine sort.

Search Result Summary Configuration - summary: For more information, see Search results summary.

Category Prediction - category_prediction and Original Search Query - raw_query: a query word and the name of category prediction.

New-search Policy - re_search: For more information, see Initiate search requests.

Business Information - biz: the user ID. For more information, see Initiate search requests.

A/B Test - abtest: the name of the A/B test.

Disabled Field - disable: one or more fields to be disabled. Example: disable = qp.

For more information about how to use extended features, see the topic of each feature.

Note

If you have any issues during the application configuration, submit a ticket for technical support.