Quick start: Create a cluster and retrieve data

Updated at:

This tutorial guides developers who are new to Alibaba Cloud Elasticsearch (ES) through the complete flow from cluster creation to data retrieval. The tutorial takes about 45 minutes, including about 20 minutes of waiting for the cluster to be created.

What you will learn

  • Create and configure an ES cluster.

  • Model data by using Developer Tools in Kibana.

    Kibana is one of the core components of ES. It lets you explore, analyze, and present the data stored in ES in an intuitive graphical way. Kibana is built into the ES console, so you do not need to install it manually.
  • Insert sample data and run various search operations.

    After you complete this tutorial, you can create an index, read and write data, and run searches in ES.

ES version and cost

Before you start, review the following key information about this trial:

  • ES type and version: Vector Enhanced Edition 8.17.0.

    This edition modularizes the core algorithm services in the AI search pipeline, including document parsing, chunking, text embedding, query analysis, retrieval, ranking, and large language model (LLM) integration. It supports semantic search, Retrieval-Augmented Generation (RAG), and multi-modal search.
  • Estimated cost: This tutorial uses pay-as-you-go billing throughout and applies a minimal configuration to keep the trial cost low: a single zone, the smallest node specifications and storage space, no dedicated master node, and no advanced enhancement features that incur additional fees. The procedure in this topic takes about 45 minutes. If you release the cluster immediately after you finish, the estimated total cost is less than CNY 20.

With the configuration recommended in this topic, you are charged for only three pay-as-you-go items: data node specifications, data node storage space, and Kibana node specifications. You can view the billing items and the unit price of each item at the bottom of the purchase page.

ES clusters are billed by the hour, and fees keep accruing as long as the cluster is running. After the trial, release the cluster immediately by following "Clean up resources and next steps" in this topic to avoid unnecessary fees.

Prerequisites

  • Register and log on to an Alibaba Cloud account. Make sure that the account has permissions to create and manage resources such as Elasticsearch and Virtual Private Cloud (VPC).

  • Create a VPC and a vSwitch, and record the region and zone where the VPC and vSwitch reside. When you create the ES cluster later, you must select the same region and zone. Otherwise, the cluster cannot be associated with the VPC and vSwitch.

Procedure

Step 1: Create a cluster (about 20 minutes)

  • Log on to the Alibaba Cloud Elasticsearch console. On the Elasticsearch Clusters page, click Create to go to the cluster purchase page. Configure the following key parameters and leave the other parameters at their default values.

ParameterDescription
Billing Method

Pay-as-you-go. You can release the cluster at any time.

Region and zone

  • Region: Select the region where the VPC and vSwitch that you created reside.

  • Zone: Three zones are selected by default. For a trial, manually switch to a single zone to reduce the waiting time for cluster creation. For a production environment, you can upgrade to multiple zones. This example uses China (Hangzhou) / Zone I.

If you keep three zones or two zones, the number of data nodes must be at least 3 and a multiple of 3, so you cannot use the 2 data nodes configured in this tutorial.
Network Type

Select the VPC and vSwitch that you created.

Cluster Type and Elasticsearch Version

Vector Enhanced Edition 8.17.0. This tutorial is based on this version.

Scenario and advanced features

Keep the default retrieval scenario. Two advanced enhancement features are enabled by default in this scenario. Handle them as follows:

  • FalconSeek high-performance search engine: Keep it enabled. It is free of charge and adds no billing item, so you can try accelerated retrieval at no cost.

  • OpenStore storage engine (high-performance retrieval): Turn it off. This feature is billed by OpenStore storage space (DFS) and cache disk space. When it is enabled, 160 GiB of shared storage is purchased by default, which incurs additional fees. This tutorial does not require it.

Data Node Specifications
  • Node specifications: 2 vCPUs and 4 GiB of memory, the smallest available option. CPU type: keep the default Intel.

  • Storage type: keep the default. Storage space per node: 20 GiB, the smallest available option.

  • Number of data nodes: 2, the smallest value that you can configure in a single zone. Data nodes store index data and mainly create, retrieve, update, and delete documents, and run aggregations.

Dedicated Master Node

Selected by default, with three nodes of 2 vCPUs and 4 GiB of memory each. This tutorial is a trial scenario, so clear the check box for the dedicated master node to reduce the cost.

A dedicated master node is responsible for cluster management, including cluster metadata. After you clear the check box, the page warns that the two data nodes have a split-brain risk. You can ignore this warning for a short functional trial, but make sure that you enable the dedicated master node before you launch production workloads.
Kibana Node

2 vCPUs and 4 GiB of memory

Cluster Name

ES_test

Password

Set a custom password. You will use this password later to log on to Kibana to build indexes and explore data.

  • Click Buy Now and wait about 20 minutes until the cluster status changes to Active. Then you can proceed to the next step.

Step 2: Configure and log on to Kibana

The public endpoint of Kibana is enabled by default. For security reasons, public network access denies all IP addresses by default. To access Kibana, you must first add the IP address of the device that you want to use to the whitelist.

Access authentication uses two-factor verification. First, log on to your Alibaba Cloud account. Then, complete a second logon with the access credentials of the ES cluster, where the username is fixed as elastic with its corresponding logon password.

  • In the left-side navigation pane, click Data Visualization. In the Kibana section, click Modify Configuration.

  • In the Network Access Configuration section, configure the Kibana public access whitelist.

Obtain the IP address of your device

Obtain the IP address of the device that you want to use based on the following scenarios.

ScenarioIP address to obtainHow to obtain it

Access Kibana from an on-premises device over the internet.

The public IP address of the on-premises device. If the device is on a home network or a corporate local area network (LAN), add the public egress IP address of the LAN instead.

Run the curl ipinfo.io/ip command to query the public IP address of the device.

Access Kibana from an Elastic Compute Service (ECS) instance over the internet.

If the ECS instance and the ES cluster are in different VPCs, you can access Kibana through the public IP address of the ECS instance. Obtain the public IP address of the ECS instance and add it to the public access whitelist of the ES cluster.

Log on to the ECS console and view the public IP address of the instance in the instance list.

Add to the public access whitelist

Obtain the IP address of your device and add it to the public access whitelist.

  • Click Configure to the right of the default group. In the dialog box that appears, add IP addresses to the whitelist.

    Configuration typeFormat and exampleImportant notes

    IPv4 address format

    • Single IP address: 192.168.0.1

    • CIDR block: 192.168.0.0/24. (Recommended) Consolidate scattered IP addresses into CIDR blocks.

    A single cluster supports a maximum of 300 IP addresses or CIDR blocks. Separate multiple IP addresses or CIDR blocks with commas (,), and do not add spaces before or after the commas.

    • Default public address: 127.0.0.1, which denies access from all IPv4 addresses.

    • 0.0.0.0/0: allows access from all IPv4 addresses.

    • Do not configure 0.0.0.0/0, because it poses a high security risk.

    • Some clusters and regions do not support 0.0.0.0/0. Refer to the console or the error message for accurate information.

  • After you complete the configuration, click OK.

  • Click Access over Internet. On the Kibana logon page, enter the username and password. After you log on successfully, you enter the Kibana console and can explore ES data.

  • Username: fixed as elastic.

  • Password: the password that you set when you created the ES cluster. If you forget it, you can reset the password.

  • Go to the Developer Tools console and run the GET / command to query the cluster information.

    Verification: If the right pane returns a JSON object that contains information such as the version number and the cluster name, the connection is successful.

Step 3: Create an index

In Kibana Developer Tools, run a RESTful API operation to create an index (mapping) named product_info for wealth management product data.

PUT /product_info
{
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1
  },
  "mappings": {
      "properties": {
        "productName": {
          "type": "text",
          "analyzer": "ik_smart"
        },
        "annual_rate":{
          "type":"keyword"
        },
        "describe": {
          "type": "text",
          "analyzer": "ik_smart"
        }
    }
  }
}

Key parameter descriptions:

settings: defines the shard configuration of the index. For example, this configuration defines five primary shards and one replica for each primary shard. mappings: defines the index fields. For example, this configuration defines three fields: productName, annual_rate, and describe. Fields of the text type support tokenization and fuzzy search, and fields of the keyword type are used for exact value matching. For more information about field types, see Field data types. Verification: If the response contains "acknowledged": true and "shards_acknowledged": true, the index was created successfully.

Step 4: Insert data

Run the following code to bulk insert test data:

POST /product_info/_bulk
{"index":{}}
{"productName":"Wealth Management Product A","annual_rate":"3.2200%","describe":"180-day fixed-term product. Minimum investment: 20,000. Stable returns. Optional push notifications."}
{"index":{}}
{"productName":"Wealth Management Product B","annual_rate":"3.1100%","describe":"90-day scheduled investment product. Minimum investment: 10,000. Daily push notifications for credited returns."}
{"index":{}}
{"productName":"Wealth Management Product C","annual_rate":"3.3500%","describe":"270-day scheduled investment product. Minimum investment: 40,000. Daily push notifications for immediately credited returns."}
{"index":{}}
{"productName":"Wealth Management Product D","annual_rate":"3.1200%","describe":"90-day scheduled investment product. Minimum investment: 12,000. Daily push notifications for credited returns."}
{"index":{}}
{"productName":"Wealth Management Product E","annual_rate":"3.0100%","describe":"Recommended 30-day scheduled investment product. Minimum investment: 8,000. Daily return message notifications."}
{"index":{}}
{"productName":"Wealth Management Product F","annual_rate":"2.7500%","describe":"Popular short-term product. 3-day term, without any service fee. Minimum investment: 500. Return notifications by SMS."}

Verification: If the response contains "errors": false, the data was inserted successfully.

Step 5: Search for data

Full-text index search (fuzzy match)

Search for the wealth management products whose describe field contains "credited returns":

GET /product_info/_search
{
  "query": {
    "match": {
      "describe": "Daily push notifications for credited returns"
    }
  }
}

Verification: The results are sorted by relevance score, and results with higher scores appear first.

Conditional search (exact match)

Search for the wealth management products whose annual_rate (annualized interest rate) is between 3.00% and 3.13%:

GET /product_info/_search
{
  "query": {
    "range": {
      "annual_rate": {
        "gte": "3.0000%",
        "lte": "3.1300%"
      }
    }
  }
}

Verification: The query exactly matches the numeric range and returns the results that meet the condition. For more information about query clauses, see Query DSL.

Clean up resources and next steps

Delete data and release the ES cluster

  • Run the following code to delete the test index that you created in this topic.

DELETE /product_info

The following response is returned:

{
"acknowledged" : true
}
  • Return to the cluster list in the Elasticsearch console.

  • In the cluster list, find the cluster that you want to release. In the Actions column, click More > Release Cluster, select Immediately Delete, and then click OK to release the cluster.

    Releasing a cluster permanently deletes the cluster and all the data in it. This action is irreversible, so proceed with caution.

Next steps

To learn more about ES, explore the following topics: