The Lindorm search engine exposes RESTful APIs compatible with Elasticsearch. Use curl to call these APIs to manage search indexes and documents.
Prerequisites
Before you begin, ensure that you have:
Activated the search engine. For more information, see Activation guide.
Added your client IP address to the Lindorm instance whitelist. For more information, see Configure a whitelist.
Connect to the search engine
Run the following command to connect and list all indexes in the cluster:
curl -XGET "http://<url>/_cat/indices?v" -u <username>:<password>Parameters
| Parameter | Description |
|---|---|
<url> | The Elasticsearch-compatible endpoint of the search engine. To get the endpoint, see Elasticsearch-compatible endpoints. |
<username> | The username to access the search engine. Get the default credentials from Database Connections > Search Engine tab in the console. |
<password> | The password to access the search engine. |
Choosing an endpoint
| Deployment | Endpoint type | Action required |
|---|---|---|
| Application on ECS | virtual private cloud (VPC) endpoint | None — VPC access provides higher security and lower latency |
| Application running locally | Internet endpoint | Enable the public endpoint first: go to Database Connections > Search Engine tab and click Enable Public Endpoint in the upper-right corner |
Example
curl -XGET "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/_cat/indices?v" -u <username>:<password>A successful connection returns the following header. If no indexes exist yet, no rows appear below it.
health status index uuid pri rep docs.count docs.deleted store.size pri.store.sizeManage indexes
The following examples use the public endpoint ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070. Replace it with your actual endpoint.
Create an index
Create an index named lindorm_search with 4 primary shards:
curl -XPUT "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/lindorm_search" \
-u <username>:<password> \
-H 'Content-Type: application/json' \
-d '{
"settings": {
"number_of_shards": 4
}
}'Each node in the search engine supports a maximum of 1,000 shards. To increase this limit, contact Lindorm technical support (DingTalk ID: s0s3eg3).
A successful operation returns:
{"acknowledged":true,"shards_acknowledged":true,"index":"lindorm_search"}acknowledged: Confirms the cluster processed the request.shards_acknowledged: Confirms all primary shards were started before the timeout.index: The name of the created index.
Set the index mapping
Define the field types for the lindorm_search index. The following example sets id as a long integer, name as a keyword, and describe as full-text:
curl -XPUT "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/lindorm_search/_doc/_mapping" \
-u <username>:<password> \
-H 'Content-Type: application/json' \
-d '{
"_doc": {
"properties": {
"id": {"type": "long"},
"name": {"type": "keyword"},
"describe": {"type": "text"}
}
}
}'A successful operation returns:
{"_index":"lindorm_search","_type":"_doc","_id":"_mapping","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}List indexes
curl -XGET "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/_cat/indices?v" \
-u <username>:<password>Example output:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open lindorm_search lindorm_search 1 0 0 0 208b 208bIf no indexes exist, only the header row is returned.
Delete an index
curl -XDELETE "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/lindorm_search" \
-u <username>:<password>A successful deletion returns:
{"acknowledged":true}Manage documents
Index a single document
Index a document with ID 1 into lindorm_search:
curl -XPOST "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/lindorm_search/_doc/1" \
-u <username>:<password> \
-H 'Content-Type: application/json' \
-d '{
"id": 100,
"name": "shenzhen",
"describe": "just a test"
}'Index multiple documents
Use the bulk API to index multiple documents in a single request. Each document requires two lines: an action line and a source line.
curl -XPOST "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/_bulk" \
-u <username>:<password> \
-H 'Content-Type: application/json' \
-d '
{ "index": { "_index": "lindorm_search", "_type": "_doc", "_id": "1" } }
{"id":200,"name":"shanghai","describe":"just"}
{ "index": { "_index": "lindorm_search", "_type": "_doc", "_id": "2" } }
{"id":300,"name":"beijing","describe":"good luck"}
'Use the bulk API when indexing large volumes of data — it reduces network overhead compared to individual requests.
Get a document by ID
Retrieve the document with ID 1:
curl -XGET "http://ld-t4n5668xk31ui****-proxy-search-public.lindorm.rds.aliyuncs.com:30070/lindorm_search/_doc/1?pretty" \
-u <username>:<password>Example output:
{
"_index" : "lindorm_search",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"id" : 100,
"name" : "shenzhen",
"describe" : "just a test"
}
}found:truemeans the document exists._version: Increments each time the document is updated._source: The original document data you indexed.
What's next
For a full list of supported REST APIs, see the Elasticsearch REST API reference.