All Products
Search
Document Center

Build an application

Last Updated: Sep 15, 2021

Create an application

Procedure:

  1. Purchase an application.

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

  3. Run a search test.

  4. Use the search algorithm center and advanced features. For example, you can analyze search results or configure sorting in the search algorithm center.

The procedure for creating a standard application is the same as that for creating an advanced application. However, a standard application does not support multiple tables. For more information, see Comparison between a standard application and an advanced application. To create an advanced application, perform the following steps:

1

1. Purchase an application

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

324

2. Configure the application

After the purchased application is initialized, the application is in the Pending state. To configure the application, click Configure on the Applications page.

78

2.1 Define an application schema

The OpenSearch console provides four methods for you to define an application schema. An advanced application supports multiple tables, which facilitates your calls in complex business scenarios.

Association relationship between a primary table and one or more secondary tables.

When you manually define an application schema and create multiple tables for the application, take note of the following association relationship among multiple tables:

  • The ratio of primary table records to secondary table records can only be N:1 or 1:1. The ratio of 1:N is not supported. This means that a primary table record cannot be associated with multiple secondary table records. In addition, only one table can be set as the primary table.

  • A secondary table can be associated with a primary table by associating the primary key of the secondary table with a foreign key of the primary table. Foreign keys of the primary table can be associated only with the primary key of the secondary table.

  • Up to two levels of association are supported.

    Examples of supported association among multiple tables:

  • Table a -> Table b, Table b -> Table c

  • Table a -> Table d

    More than two levels of association are not supported. Example of unsupported association among multiple tables:

  • Table a -> Table b, Table b -> Table c, Table c -> Table d

    Cyclical association is not supported. Example of cyclical association among multiple tables:

  • Table a -> Table b, Table b -> Table a

    Data model

9
  • Procedure for defining an application schema:

  • 1. Use a template to define an application schema. You can create a template by using a self-defined application schema and then use the template to create an application with ease.

  • 2. Use a data file to define an application schema. You can upload a data file to the OpenSearch console. Then, OpenSearch automatically resolves 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.

  • 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.

1011
  • 4. Manually define an application schema.

12

2.2 Define an index schema

  • You must use the fields that are applied in QUERY clauses to create index fields. Fields of the FLOAT type cannot be used to create index fields. For more information about the method of splitting words, see Fields and word-splitting types.

  • You must use the following fields to create attribute fields: fields that are applied in FILTER, SORT, AGGREGATE, or DISTINCT clauses, and fields that must be set to attribute fields as specified by corresponding functions.

  • You cannot create attribute fields by using fields of text types, such as TEXT and SHORT_TEXT. You can create 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.

13

2.3 Configure a data source

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

14

After you confirm your selection, 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

2.4 Complete the configuration

17

3. Run a search test

After the data source is configured, you can start to search for data. The OpenSearch console provides the Search Test page for you to run search tests. You can configure clauses and fields to search for data based on your business requirements. The following example describes how to use the Search Test page. For more information about other search methods, see List of operations by function, Tutorial of using the SDK for Java, or Tutorial of using the SDK for PHP. To run a search test on the Search Test page, move the pointer over the Plus icon next to Clauses or Fields, select a clause or field that you want to use from the drop-down list, specify the clause or field, and then click Search.

Procedure

1.In the left-side navigation pane, choose Feature Extensions > Search Test. On the Search Test page, enter a required QUERY clause.

18

2.You can add more clauses or fields as required.

1919

Clause description

  • For more information about how to use QUERY clauses, see QUERY clauses.

  • For more information about how to use FILTER clauses, see FILTER clauses.

  • For more information about how to use SORT clauses, see SORT clauses.

  • For more information about how to use DISTINCT clauses, see DISTINCT clauses.

  • For more information about how to use AGGREGATE clauses, see AGGREGATE clauses.

  • For more information about how to use KVPAIR clauses, see KVPAIR clauses.

  • For more information about how to use CONFIG clauses, see CONFIG clauses.

Field description

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

  • Query Analysis - qp: Sets the name of query analysis.

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

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

  • Search Result Summary Configuration - summary: Configures the summary of search results. For more information, see Search processing.

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

  • New-search Policy - re_search: Sets a re-search policy. For more information, see Search processing.

  • Business Information - biz and User ID - user_id: Sets business information and the user ID. For more information, see Search processing.

  • A/B Test - abtest: Sets the name of A/B testing.

  • Disabled Field - disable: Disables one or more fields. Example: disable = qp.

  • For more information about how to use advanced features, see corresponding topics.