{"version": "2.0","statement": [{"effect": "allow","action": ["cls:SearchLog"],"resource": ["*"]}]}
GET /${topic_id}/_searchPOST /${topic_id}/_searchGET /${searchview_id}/_searchPOST /${searchview_id}/_searchPOST /${topic_id}/_msearchPOST /${searchview_id}/_msearchPOST /_msearchGET /${topic_id}/_mappingGET /${searchview_id}/_mappingPOST /${topic_id}/_field_capsPOST /${searchview_id}/_field_caps
${topic_id}: log topic ID, equivalent to an index in Elasticsearch. You can obtain it on the Log Topic List page. Only one topic ID can be specified. To query multiple topics at the same time, use ${searchview_id}.${searchview_id}: search view ID. A search view can contain multiple topics. You need to create the search view in advance through the API.X-CLS-ES-Protocol-Version: v1 to all requests.DSL Syntax | Description |
from | Pagination start offset. Specifies the record number from which to start returning data. Use with size. A maximum of 10,000 records can be queried using from + size in total. |
size | Number of documents returned per page. Controls how many records are displayed on the current page. |
sort | Specifies the field for sorting. The field used for sorting must have indexing enabled, and statistics must be enabled in the index configuration. |
track_total_hits | Whether to accurately count the total number of matched documents. By default, accurate counting is limited to 10,000. |
DSL Syntax | Description |
bool | Combine multiple query conditions. |
filter | Filter condition that must be met. |
should | Optional match condition that functions like OR. It can be used with minimum_should_match to specify the minimum number of should conditions that must be met. |
minimum_should_match | Specifies the minimum number of conditions that must be met in bool.should. For example, setting it to 1 means that at least one should condition must be met. |
must | Condition that must be met. |
must_not | Condition that must not be met. |
match | Full-text search. |
term | Matches a single value. |
terms | Matches multiple values (similar to SQL IN). |
range | Range query (for numeric values and similar data). |
match_all | Queries all documents. |
multi_match | Performs full-text search across multiple fields. |
match_phrase | Phrase matching that requires consistent word order. |
exists | Checks whether a field exists or is not empty. |
ids | Queries by document ID. |
prefix | Prefix matching. |
wildcard | Wildcard matching (* and ?), but cannot start with a wildcard. |
query_string | Advanced query that supports Lucene syntax. |
regexp | Regular expression matching. |
search_after | Performs deep pagination based on the sort value of the previous page. |
DSL Syntax | Description |
avg | Calculate the average value of a numeric field, for example, calculate the average price of products. |
sum | Calculate the sum of a numeric field, for example, calculate the total sales for a single day. |
max | Obtain the maximum value of a numeric field, for example, find the highest user points. |
min | Obtain the minimum value of a numeric field, for example, find the lowest product inventory. |
value_count | Count the number of field values, for example, count the number of order IDs. |
percentiles | Calculate percentiles to analyze data distribution, for example, calculate the response time in milliseconds within which 95% of requests are completed. |
cardinality | Approximate deduplication counting, for example, count the number of unique visitors (UV). |
top_hits | Obtain the top documents in each group, for example, view the top 3 products by sales in each category. |
terms | Group by field values, similar to SQL GROUP BY, for example, count the number of items by product category. |
filter | Filter documents by one filter condition and then perform statistics, for example, count only paid orders. |
filters | Group and count by multiple filter conditions separately, for example, count paid and unpaid orders separately. |
range | Group by custom numeric ranges, for example, count the number of products in the price ranges 0-100 and 100-500 separately. |
date_range | Group by custom date ranges, for example, count orders for this year and last year separately. Only the @timestamp field is supported. |
histogram | Group by fixed numeric intervals, for example, count the number of products in each CNY 100 interval. |
date_histogram | Group by fixed time intervals, for example, count orders by day, week, or month. Only the @timestamp field is supported. |
Elasticsearch | CLS | Description |
@timestamp | __TIMESTAMP__ | When the query statement specifies the @timestamp field, the actual query targets the __TIMESTAMP__ field in CLS. |
level is WARNING within the time range from 2026-06-09T07:38:04.240 to 2026-06-09T07:53:04.240 (UTC time zone):curl -X POST "https://ap-guangzhou.cls.tencentcs.com/elasticsearch/34373f59-b5cc-4a54-902a-4a98cade60ea/_search" \\-H "Content-Type: application/json" \\-H "X-CLS-ES-Protocol-Version: v1" \\-u AKIDxxxxxxxxxxxxxxxxxxxxxxxxxx:B9xxxxxxxxxxxxxxxxxxxxxxx \\-d '{"track_total_hits": false,"from": 0,"size": 10,"sort": [{"@timestamp": {"order": "desc"}}],"query": {"bool": {"filter": [{ "match": { "level": "WARNING" } },{"range": {"@timestamp": {"gte": "2026-06-09T07:38:04.240Z","lt": "2026-06-09T07:53:04.240Z"}}}]}}}'
user-service within the time range from 2026-06-09T07:38:04.240 to 2026-06-09T07:53:04.240 (UTC time zone), and count the number of logs grouped by level:curl -X POST "https://ap-guangzhou.cls.tencentcs.com/elasticsearch/34373f59-b5cc-4a54-902a-4a98cade60ea/_search" \\-H "Content-Type: application/json" \\-H "X-CLS-ES-Protocol-Version: v1" \\-u AKIDxxxxxxxxxxxxxxxxxxxxxxxxxx:B9xxxxxxxxxxxxxxxxxxxxxxx \\-d '{"size": 0,"query": {"bool": {"filter": [{"multi_match": {"type": "best_fields","query": "user-service","lenient": true}},{"range": {"@timestamp": {"gte": "2026-06-09T07:38:04.240Z","lt": "2026-06-09T07:53:04.240Z"}}}]}},"aggs": {"level_distribution": {"terms": {"field": "level","size": 100,"min_doc_count": 1}}}}'
피드백