ALIYUN::OTS::SearchIndex is used to create a search index for a data table. You can create multiple search indexes for a data 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 name of the search index. | None. |
InstanceName | String | Yes | No | The name of the instance to which the data table belongs. | None. |
TableName | String | Yes | No | The name of the data table. | None. |
FieldSchemas | List | Yes | No | The list of field schemas. | None. |
IndexSort | Map | No | No | The presorting settings of the search index. By default, data is sorted by primary key. | You can skip the presorting settings for the search indexes that contain fields of the nested data type. For more information, see IndexSort property. |
IndexSetting | Map | No | No | The settings of the search index. | 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. | You can use the PrimaryKeySort and FieldSort methods. 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 | Specifies to sort data by field value. | For more information, see FieldSort properties. |
PrimaryKeySort | Map | No | No | Specifies to sort data by primary key. | For more information, see PrimaryKeySort property. |
ScoreSort | Map | No | No | Specifies to sort data based on the BM25-based keyword relevance score. ScoreSort is suitable for relevance scenarios such as full-text search. | You must configure ScoreSort to sort the matched data by keyword relevance score. Otherwise, the matched data is sorted based on the presorting settings that are specified by IndexSort. For more information, see ScoreSort property. |
GeoDistanceSort | Map | No | No | Specifies to sort data by geographical location. | 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 sorting method that is used when the field has multiple values. | None. |
SortOrder | String | No | No | The sorting order. | Valid values:
|
FieldName | String | Yes | No | The name of the field that is used to sort data. | None. |
PrimaryKeySort syntax
"PrimaryKeySort": {
"SortOrder": String
}
PrimaryKeySort property
Property | Type | Required | Editable | Description | Constraint |
SortOrder | String | No | No | The sorting order. | Valid values:
|
ScoreSort syntax
"ScoreSort": {
"SortOrder": String
}
ScoreSort property
Property | Type | Required | Editable | Description | Constraint |
SortOrder | String | No | No | The sorting order. | Valid values:
|
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 of the points that compose the polygon. You can specify a polygon by using multiple coordinates. | Specify the coordinates in the |
SortMode | String | No | No | The sorting method that is used when the field has multiple values. | None. |
SortOrder | String | No | No | The sorting order. | Valid values:
|
FieldName | String | Yes | No | The name of the field that is 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. | You can specify some primary key columns as routing fields. Tablestore distributes data that is written to a search index to different partitions based on the specified routing fields. The data whose routing field values are the same is distributed 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 | Specifies whether to enable indexing. | Valid values:
|
IsArray | Boolean | No | No | Specifies whether the value is an array. | Valid values:
|
Analyzer | String | No | No | The type of the analyzer. | If the field is of the text data type, you can specify this property. If the field is of a different data type, single-word tokenization is used as the analyzer type by default. For more information, see Tokenization. |
EnableSortAndAgg | Boolean | No | No | Specifies whether to enable the sorting and aggregation features. | Valid values:
|
Store | Boolean | No | No | Specifies whether to store the value of the field in the search index. | Valid values:
If you set Store to true, you can read the value of the field from the search index without the need to query the data table. This improves query performance. |
SubFieldSchemas | List | No | No | The list of field schemas for subfields. If the field is of the nested data type, you must specify this property to configure the index types of subfields in the nested field. | None. |
FieldName | String | Yes | No | The name of the field in the search index. The name is also called the column name. | A field in a search index can be a primary key column or an attribute column. |
FieldType | String | Yes | No | The data type of the field. | Specify the data type in the FieldType.XXX format. Valid values:
For more information, see Data type mappings. |
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 | Specifies whether to enable indexing. | Valid values:
|
IsArray | Boolean | No | No | Specifies whether the value is an array. | Valid values:
|
Analyzer | String | No | No | The type of the analyzer. | If the field is of the text data type, you can specify this property. If the field is of a different data type, single-word tokenization is used as the analyzer type by default. For more information, see Tokenization. |
EnableSortAndAgg | Boolean | No | No | Specifies whether to enable the sorting and aggregation features. | Valid values:
|
Store | Boolean | No | No | Specifies whether to store the value of the field in the search index. | Valid values:
If you set Store to true, you can read the value of the field from the search index without the need to query the data table. This improves query performance. |
FieldName | String | Yes | No | The name of the field in the search index. The name is also called the column name. | A field in a search index can be a primary key column or an attribute column. |
FieldType | String | Yes | No | The data type of the field. | Specify the data type in the FieldType.XXX format. For more information, see Data type mappings. |
Return values
Fn::GetAtt
IndexName: the name of the search index.
Examples
For more examples, visit ots.yml. In the examples, the ALIYUN::OTS::Instance, ALIYUN::OTS::SearchIndex, ALIYUN::OTS::Table, and ALIYUN::OTS::VpcBinder resource types are used.