All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::OTS::SearchIndex

Last Updated:Jun 03, 2026

ALIYUN::OTS::SearchIndex creates a search index on a data table. You can create multiple search indexes on a single table.

Syntax

{
  "Type": "ALIYUN::OTS::SearchIndex",
  "Properties": {
    "IndexName": String,
    "InstanceName": String,
    "TableName": String,
    "FieldSchemas": List,
    "IndexSort": Map,
    "IndexSetting": Map
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

IndexName

String

Yes

No

The search index name.

None.

InstanceName

String

Yes

No

The instance that contains the data table.

None.

TableName

String

Yes

No

The data table name.

None.

FieldSchemas

List

Yes

No

The field schemas.

None.

IndexSort

Map

No

No

The search index presorting settings. Default: sorted by primary key.

You can skip presorting for search indexes that contain nested fields.

For more information, see IndexSort property.

IndexSetting

Map

No

No

The search index settings.

For more information, see IndexSetting property.

IndexSort syntax

"IndexSort": {
  "Sorters": List
}

IndexSort property

Property

Type

Required

Editable

Description

Constraint

Sorters

List

Yes

No

The presorting method.

Supported methods: PrimaryKeySort and FieldSort.

For more information, see Sorting and paging and Sorters properties.

Sorters syntax

"Sorters": [
  {
    "FieldSort": Map,
    "PrimaryKeySort": Map,
    "ScoreSort": Map,
    "GeoDistanceSort": Map
  }
]

Sorters properties

Property

Type

Required

Editable

Description

Constraint

FieldSort

Map

No

No

Sorts data by field value.

For more information, see FieldSort properties.

PrimaryKeySort

Map

No

No

Sorts data by primary key.

For more information, see PrimaryKeySort property.

ScoreSort

Map

No

No

Sorts data by BM25-based keyword relevance score. Suitable for full-text search scenarios.

Required to sort matched data by relevance score. Without ScoreSort, matched data follows the IndexSort presorting settings.

For more information, see ScoreSort property.

GeoDistanceSort

Map

No

No

Sorts data by geographical distance.

For more information, see GeoDistanceSort properties.

FieldSort syntax

"FieldSort": {
  "SortMode": String,
  "SortOrder": String,
  "FieldName": String
}

FieldSort properties

Property

Type

Required

Editable

Description

Constraint

SortMode

String

No

No

The sort method when the field has multiple values.

None.

SortOrder

String

No

No

The sort order.

Valid values:

  • ASC (default): ascending order

  • DESC: descending order

FieldName

String

Yes

No

The field used to sort data.

None.

PrimaryKeySort syntax

"PrimaryKeySort": {
  "SortOrder": String
}

PrimaryKeySort property

Property

Type

Required

Editable

Description

Constraint

SortOrder

String

No

No

The sort order.

Valid values:

  • ASC (default): ascending order

  • DESC: descending order

ScoreSort syntax

"ScoreSort": {
  "SortOrder": String
}

ScoreSort property

Property

Type

Required

Editable

Description

Constraint

SortOrder

String

No

No

The sort order.

Valid values:

  • ASC (default): ascending order

  • DESC: descending order

GeoDistanceSort syntax

"GeoDistanceSort": {
  "Points": List,
  "SortMode": String,
  "SortOrder": String,
  "FieldName": String
}

GeoDistanceSort properties

Property

Type

Required

Editable

Description

Constraint

Points

List

Yes

No

The coordinates that form the polygon.

Specify the coordinates in the latitude,longitude format. Valid values of latitude: [-90,+90]. Valid values of longitude: [-180,+180]. Sample value of Points: 35.8,-45.91.

SortMode

String

No

No

The sort method when the field has multiple values.

None.

SortOrder

String

No

No

The sort order.

Valid values:

  • ASC (default): ascending order

  • DESC: descending order

FieldName

String

Yes

No

The field used to sort data.

None.

IndexSetting syntax

"IndexSetting": {
  "RoutingFields": List
}

IndexSetting property

Property

Type

Required

Editable

Description

Constraint

RoutingFields

List

No

No

The custom routing fields.

Specify primary key columns as routing fields. Tablestore distributes data written to a search index across partitions based on routing field values. Data with the same routing field values goes to the same partition.

FieldSchemas syntax

"FieldSchemas": [
  {
    "Index": Boolean,
    "IsArray": Boolean,
    "Analyzer": String,
    "EnableSortAndAgg": Boolean,
    "Store": Boolean,
    "SubFieldSchemas": List,
    "FieldName": String,
    "FieldType": String
  }
]

FieldSchemas properties

Property

Type

Required

Editable

Description

Constraint

Index

Boolean

No

No

Whether to enable indexing.

Valid values:

  • true

  • false

IsArray

Boolean

No

No

Whether the value is an array.

Valid values:

  • true

  • false

Analyzer

String

No

No

The analyzer type.

Applicable to text fields. Non-text fields default to single-word tokenization.

For more information, see Tokenization.

EnableSortAndAgg

Boolean

No

No

Whether to enable sorting and aggregation.

Valid values:

  • true

  • false

Store

Boolean

No

No

Whether to store the field value in the search index.

Valid values:

  • true

  • false

If set to true, the field value can be read directly from the search index without querying the data table, which improves query performance.

SubFieldSchemas

List

No

No

The subfield schemas. Required for nested fields to configure subfield index types.

None.

FieldName

String

Yes

No

The field name in the search index, also called the column name.

Can be a primary key column or an attribute column.

FieldType

String

Yes

No

The field data type.

Use the FieldType.XXX format.

Valid values:

  • FieldType.LONG

  • FieldType.DOUBLE

  • FieldType.BOOLEAN

  • FieldType.KEYWORD

  • FieldType.GEOPOINT

  • FieldType.NESTED

For more information, see Data types.

SubFieldSchemas syntax

"SubFieldSchemas": [
  {
    "Index": Boolean,
    "IsArray": Boolean,
    "Analyzer": String,
    "EnableSortAndAgg": Boolean,
    "Store": Boolean,
    "FieldName": String,
    "FieldType": String
  }
]

SubFieldSchemas properties

Property

Type

Required

Editable

Description

Constraint

Index

Boolean

No

No

Whether to enable indexing.

Valid values:

  • true

  • false

IsArray

Boolean

No

No

Whether the value is an array.

Valid values:

  • true

  • false

Analyzer

String

No

No

The analyzer type.

Applicable to text fields. Non-text fields default to single-word tokenization.

For more information, see Tokenization.

EnableSortAndAgg

Boolean

No

No

Whether to enable sorting and aggregation.

Valid values:

  • true

  • false

Store

Boolean

No

No

Whether to store the field value in the search index.

Valid values:

  • true

  • false

If set to true, the field value can be read directly from the search index without querying the data table, which improves query performance.

FieldName

String

Yes

No

The field name in the search index, also called the column name.

Can be a primary key column or an attribute column.

FieldType

String

Yes

No

The field data type.

Use the FieldType.XXX format.

For more information, see Data types.

Return values

Fn::GetAtt

IndexName: the search index name.

Examples

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  InstanceName:
    Type: String
    Description: The name of the OTS instance in which table will locate.
    AllowedPattern: '[a-zA-Z][-a-zA-Z0-9]{1,14}[a-zA-Z0-9]'
    Default: mytest
  TableName:
    Type: String
    Description: The table name of the OTS instance.
    AllowedPattern: '[_a-zA-Z][_a-zA-Z0-9]{0,254}'
    Default: mytest
  SearchIndexName:
    Type: String
    Description: The index name.
    Default: searchIndex
  FieldSchemas:
    Type: Json
    Default:
      - FieldName: id
        FieldType: FieldType.LONG
        IsArray: false
        Index: true
        EnableSortAndAgg: true
        Store: true
Resources:
  SearchIndex:
    Type: ALIYUN::OTS::SearchIndex
    Properties:
      IndexName:
        Ref: SearchIndexName
      InstanceName:
        Ref: InstanceName
      TableName:
        Ref: TableName
      FieldSchemas:
        Ref: FieldSchemas
Outputs:
  IndexName:
    Value:
      Fn::GetAtt:
        - SearchIndex
        - IndexName

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "InstanceName": {
      "Type": "String",
      "Description": "The name of the OTS instance in which table will locate.",
      "AllowedPattern": "[a-zA-Z][-a-zA-Z0-9]{1,14}[a-zA-Z0-9]",
      "Default": "mytest"
    },
    "TableName": {
      "Type": "String",
      "Description": "The table name of the OTS instance.",
      "AllowedPattern": "[_a-zA-Z][_a-zA-Z0-9]{0,254}",
      "Default": "mytest"
    },
    "SearchIndexName": {
      "Type": "String",
      "Description": "The index name.",
      "Default": "searchIndex"
    },
    "FieldSchemas": {
      "Type": "Json",
      "Default": [
        {
          "FieldName": "id",
          "FieldType": "FieldType.LONG",
          "IsArray": false,
          "Index": true,
          "EnableSortAndAgg": true,
          "Store": true
        }
      ]
    }
  },
  "Resources": {
    "SearchIndex": {
      "Type": "ALIYUN::OTS::SearchIndex",
      "Properties": {
        "IndexName": {
          "Ref": "SearchIndexName"
        },
        "InstanceName": {
          "Ref": "InstanceName"
        },
        "TableName": {
          "Ref": "TableName"
        },
        "FieldSchemas": {
          "Ref": "FieldSchemas"
        }
      }
    }
  },
  "Outputs": {
    "IndexName": {
      "Value": {
        "Fn::GetAtt": [
          "SearchIndex",
          "IndexName"
        ]
      }
    }
  }
}

The ots.yml template uses the ALIYUN::OTS::Instance, ALIYUN::OTS::SearchIndex, ALIYUN::OTS::Table, and ALIYUN::OTS::VpcBinder resource types.