You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Index management API
CreateIndex
Copy page
Download PDF
CreateIndex
Call the CreateIndex API to create an index.​
Usage instructions​
This API creates an index for a log topic. The call frequency is limited to 20 times per second. If the frequency limit is exceeded, an ExceedQPSLimit error is returned.​
tip​
  • At least enable one index between full-text index and key-value index. If no index is enabled, logs that are collected can not be searched.​
  • TLS words have a character limit of 32,766 characters. If you do not set a delimiter, logs whose full-text or word fields are too long might be discarded.​
  • If you enable key-value index for a field but do not enable statistics, and if a delimiter is not set or the field contains Chinese, the field will not be tokenized.​
  • If both key-value index and statistics are enabled for a field, the delimiter attribute is ineffective.​
Request instructions​
  • Request method: POST​
  • Request URL: https://{tls-endpoint}/CreateIndex​
Request parameters​
The table below lists only the unique request parameters for this API and some common parameters. For more information, see Common parameters.​
Body​
​
Parameters​
Type​
Required​
Example value​
Description​
TopicId​
String​
Yes​
4a*********​
Log topic ID.​
FullText​
Object of FullTextInfo​
No​
/​
Full-text index configuration​
  • If this field is null or not configured, full-text index will not be enabled​
  • At least one of the full-text index configuration or key-value index configuration must be specified; that is, at least one parameter between FullText and KeyValue should be defined​
KeyValue​
Array of KeyValueInfo​
No​
/​
Key-value index configuration.​
  • If the array length of this field is 0 or not configured, key-value index is disabled.​
  • At least one of Full-text index or key-value index configuration must be set; at least one parameter must be specified between FullText and KeyValue.​
UserInnerKeyValue​
Array of KeyValueInfo​
No​
/​
Reserved field index configuration.​
  • If the length of this field array is 0 or it is not configured, the reserved field index is not enabled.​
  • You cannot enable both Full-text index and the key-value index for the reserved field __content__ at the same time. If you set the __content__ index using the UserInnerKeyValue parameter, do not set the FullText parameter simultaneously.​
  • Currently, you can only manually enable indexing for __content__ among reserved fields. For index settings of other reserved fields, see Reserved fields.​
MaxTextLen​
Integer​
No​
2048​
Maximum length of field value for statistics. Default is 2048 bytes, with a range of 64–1048576 bytes.​
tip​
  • If the length of a single field value exceeds your specified maximum, the excess will be truncated and not included in analysis.​
  • After updating the maximum field length, the change only applies to incremental data.​
EnableAutoIndex​
Boolean​
No​
true​
Enable automatic index updates. When enabled, the system will automatically add newly detected fields to the key-value index​
  • true: Enable automatic updates​
  • false: Do not enable automatic updates​
​
FullTextInfo​
​
Parameters​
Type​
Required​
Example value​
Description​
Delimiter​
String​
Yes​
, ;/\n\t​
Delimiter for full-text index.​
  • Each character in the string represents a delimiter.​
  • Length must be between 1 and 256 bytes.​
  • Only supports one or more of the following characters:​
  • Uppercase and lowercase letters, numbers, and !@#%^&*()-_=\\\"', <>/?|;:\n\t\r[]{}.​
  • Supports configuration with both Chinese characters and delimiters.​
CaseSensitive​
Boolean​
Yes​
false​
Case sensitive.​
  • true: case sensitive.​
  • false: not case sensitive.​
IncludeChinese​
Boolean​
No​
false​
When querying, split the Chinese content of logs based on Chinese grammar. The default is false.​
  • true:​
  • Chinese characters in logs: Logs are split based on common Chinese grammar rules. Delimiter that contains custom Chinese content is not supported.​
  • Non-Chinese characters in logs: Split logs based on the delimiter specified in the delimiter parameter.​
  • false: Logs are split according to the delimiter specified by the delimiter parameter.​
​
KeyValueInfo​
​
Parameters​
Type​
Required​
Example value​
Description​
Key​
String​
Yes​
"Key": "test-key1"​
Specify the field names to be configured for the key-value index, with up to 100 fields allowed.​
  • Support only letters, numbers, spaces, underscores (_), hyphens (-), and slashes (/). Do not support starting or ending with space.​
  • Within the same index, the key name must be unique.​
  • Length must be between 1 and 128 characters.​
tip​
For subfields of JSON type key-value indexes, use a period (.) to indicate the hierarchy between JSON fields. For example, if the JSON field "namelist" contains a subfield "totalcount" of type text and another JSON type subfield "info," which in turn contains the field "name," the fields should be configured as "totalcount" and "info.name," respectively.​
Value​
Object of Value​
Yes​
"Value": { "ValueType": "text", "Delimiter": "", "CaseSensitive": true, "IncludeChinese": false, "SqlFlag": false }​
Description of fields that require key-value index configuration.​
​
Value​
​
Parameters​
Type​
Required​
Example value​
Description​
SqlFlag​
Boolean​
No​
false​
Enable analysis for this field. The default value is false.​
After you enable statistics and analysis, you can configure delimiters and support for Contains Chinese.​
IndexAll​
Boolean​
No​
false​
Create an index for all fields containing text values in a JSON field.​
JsonKeys​
Array of KeyValueInfo​
No​
[ { "Key":"key1", "Value":{ "ValueType":"text", "SqlFlag":true } }, { "Key":"key2", "Value":{ "ValueType":"long", "SqlFlag":true } }, { "Key":"key3.key4.key5", "Value":{ "ValueType":"double", "SqlFlag":true } } ]​
When ValueType is set to json, you can configure JSON subfield key-value indexing through the JsonKeys field. Its value should be an array of KeyValueInfo objects.​
  • Each element in the JsonKeys list is a KeyValueInfo, which can further define nested subfields of type text, long, or double.​
  • For subfields in JSON key-value indexing, use . to indicate hierarchy between JSON fields. For example, if the JSON field namelist contains a text-type subfield totalcount and a JSON-type subfield info, and info contains the field name, the field names should be set as totalcount and info.name, respectively.​
  • The SqlFlag setting for subfield key-value indexes defined in JsonKeys should match the parent field; both must be enabled or disabled together. The default state is disabled. Subfields do not support separate Delimiter, CaseSensitive, or IncludeChinese settings. For fields of type text, CaseSensitive, Delimiter, and IncludeChinese always follow their parent field settings.​
  • Only set when ValueType is json.​
Delimiter​
String​
No​
, ;/\n\t​
The delimiter for the field. Default is empty ("").​
  • Each character in the string represents a delimiter.​
  • Length must be between 0 and 256 bytes. When the length is 0, tokenization is not applied.​
  • Only the following characters are supported: one or more from the list below.​
  • Uppercase and lowercase letters, numbers, and !@#%^&*()-_=\\\"', <>/?|;:\n\t\r[]{}.​
  • Supports simultaneous configuration with both Contains Chinese and Delimiter.​
ValueType​
String​
Yes​
text​
Field type.​
  • Currently supports long, double, text, and json.​
  • The long and double types do not support configuring delimiters, contain Chinese, or are case sensitive​
  • Only the json type supports further configuration of JsonKeys subfields​
CaseSensitive​
Boolean​
No​
true​
Case sensitivity. The default value is false.​
IncludeChinese​
Boolean​
No​
false​
When querying, TLS can split the Chinese content of logs according to Chinese grammar. You can choose to enable or disable this function.​
  • Enable:​
  • Chinese characters in logs: Logs are split based on common Chinese grammar rules. Delimiter that contains custom Chinese content is not supported.​
  • Non-Chinese characters in logs: Split logs based on the delimiter specified in the delimiter parameter.​
  • Disabled: Split logs based on the delimiter specified in the delimiter parameter.​
Description​
String​
No​
test​
Description information of the indexed fields.​
IndexSQLAll​
Boolean​
No​
false​
Enable automatic indexing and statistics for JSON fields.​
  • true: Enable automatic indexing and statistics.​
  • false: Disable automatic indexing and statistics.​
AutoIndexFlag​
Boolean​
No​
false​
Indicates whether the index is added automatically​
  • true: The index is added automatically​
  • false: The index is not added automatically​
​
Response parameters​
The table below lists only the return parameters specific to this interface For more information, see Return Structure.​
​
Parameters​
Type​
Example value​
Description​
TopicId​
String​
3***********​
Log topic ID.​
​
Sample request 1​
Full-text index example​
​
POST https://{tls-endpoint}/CreateIndex HTTP/1.1​
Content-Type: application/json​
{​
"TopicId": "3***********",​
"FullText": {​
"Delimiter": ",-;",​
"CaseSensitive": false,​
"IncludeChinese": false​
}​
}​
​
Sample response 1​
​
HTTP/1.1 200 OK​
Content-Type: application/json; charset=utf-8​
{​
"TopicId": "39**********"​
}​
​
Sample request 2​
Full-text index and key-value index example​
​
POST https://{tls-endpoint}/CreateIndex HTTP/1.1​
Content-Type: application/json​
{​
"TopicId": "4a*********",​
"FullText": {​
"Delimiter": ", ;/\\n\\t",​
"CaseSensitive": false,​
"IncludeChinese": false​
},​
"KeyValue": [​
{​
"Key": "test-key1",​
"Value": {​
"ValueType": "text",​
"Delimiter": "",​
"CaseSensitive": true,​
"IncludeChinese": false,​
"SqlFlag": false,​
"IndexAll": false,​
"JsonKeys": [],​
"Description":test,​
"IndexSQLAll": false,​
"AutoIndexFlag": false​
}​
}​
],​
"UserInnerKeyValue": [],​
"MaxTextLen": 2048,​
"EnableAutoIndex": true​
}​
​
Sample response 2​
​
HTTP/1.1 200 OK​
Content-Type: application/json; charset=utf-8​
{​
"TopicId": "39**********"​
}​
​
Sample request 3​
Key-value index and reserved field index example​
​
POST https://{tls-endpoint}/CreateIndex HTTP/1.1​
Content-Type: application/json​
{​
"TopicId": "4a*********",​
"FullText": {​
"Delimiter": ", ;/\\n\\t",​
"CaseSensitive": false,​
"IncludeChinese": false​
},​
"KeyValue": [​
{​
"Key": "test-key1",​
"Value": {​
"ValueType": "text",​
"Delimiter": "",​
"CaseSensitive": true,​
"IncludeChinese": false,​
"SqlFlag": false,​
"IndexAll": false,​
"JsonKeys": [],​
"Description":test,​
"IndexSQLAll": false,​
"AutoIndexFlag": false​
}​
}​
],​
"UserInnerKeyValue": [],​
"MaxTextLen": 2048,​
"EnableAutoIndex": true​
}​
​
Return sample 3​
​
HTTP/1.1 200 OK​
Content-Type: application/json; charset=utf-8​
{​
"TopicId":"39**********"​
}​
​
Error Code​
The table below lists error codes related to the API and business logic. For public error codes, see the Public Error Code documentation.​
​
HTTP status code​
Error Code​
Error message​
Description​
400​
InvalidArgument​
Invalid argument key %s, value %s, please check argument.​
Delimiter and middle segmentation cannot be configured at the same time.​
400​
InvalidArgument​
At least one of full-text indexing and key-value indexing must be turned on.​
You must enable either the full-text index or the key-value index.​
400​
InvalidArgument​
Index key value_type:%s conflict with [includeChinese:%t, casSensitive:%t, delimiter:%s], please check argument.​
Configuration for long/double types does not support values that contain Chinese, are case sensitive, or include delimiter.​
400​
InvalidIndexJsonKeys​
Non-JSON field %s configures JsonKeys, please check argument.​
Non-JSON field configuration subfield​
400​
ConflictIndexJsonKeys​
JsonKeys %s and %s have conflict prefix, please check argument.​
There is a prefix conflict in JsonKeys key names​
400​
InvalidArgument​
Index key sqlFlag:%t conflict with [includeChinese:%t, delimiter:%s], please check argument.​
Once statistics are enabled, configuring content with Chinese characters or delimiters is not supported.​
400​
IndexKeyValueQuotaExceed​
Exceeded index key-value quota.​
Key-value index limit exceeded.​
400​
IndexKeyDuplicate​
The %dth index key name:%s is duplicate, please check argument.​
The index key name is duplicated.​
400​
InvalidArgument​
Index key delimiter:%s conflict with includeChinese:%t, please check argument.​
Delimiter and middle segmentation cannot be set together.​
400​
IndexKVNULL​
Index key value index is open, but the key value list is null, please check argument.​
The configured number of keys for the key-value index is 0.​
404​
TopicNotExist​
Topic does not exist.​
Log topic does not exist.​
409​
IndexAlreadyExist​
Index already exist​
The index already exists.​
500​
InternalServerError​
We encountered an unexpected server error, please try again later.​
Internal server error.​
400​
IndexInnerKeyUnSupport​
key-value indexing for inner key: %v, doesn't support​
Setting a reserved field index for the %v field is not supported.​
400​
IndexInnerKeyConflict​
full-text indexing and content indexing can't be set together​
There is a conflict between the full-text index and the __content__ index configuration.​
​
Last updated: 2026.07.08 15:45:24