Back

Tengence Search API Reference

Tengence Team ·
API Integration Search System Tengence Search
Tengence Search API Reference

Tengence Search is a high-performance intelligent search service that provides full-text search, smart aggregation, and flexible filtering to help you quickly build a professional search experience.

Table of Contents


Quick Start

Basic Information

Item Description
Endpoint https://api.tengence.com/v1/search
Method POST
Content-Type application/json
Charset UTF-8

Quick Example

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "page": 1,
    "size": 10
  }'

Authentication

All endpoints require an API Key in the request header:

Authorization: Bearer {YOUR_API_KEY}

Get an API Key: Sign in to the Tengence Console (https://console.tengence.com) and copy the API Key from the Application Details page.

{
  "code": "SUCCESS",
  "message": "Operation successful",
  "data": {
    "items": [
      {
        "id": "123",
        "title": "AI Agent Platform",
        "price": 4999
      }
    ],
    "total": 1520,
    "aggs": [],
    "took": 45
  },
  "success": true
}

Search Endpoint

POST https://api.tengence.com/v1/search

Method: POST

Sends a search request and returns the matched results.

Request Headers

Parameter Type Required Description
Authorization string Yes Bearer {YOUR_API_KEY}
Content-Type string Yes application/json

Request Parameters

Parameter Type Required Default Description
query string Yes – Search keyword
page number No 1 Page number, starting from 1
size number No 20 Results per page, maximum 100
sortFields array No – List of sort fields
highlightFields array No – List of highlighted fields
aggregations array No – Aggregation configuration list
searchFields array No – Restrict search to specific fields
includeFields array No – Restrict returned fields
filters array No – List of filter conditions

filters Parameter Structure

The filters parameter is used for precise filtering of search results and supports multiple operators.

FilterParam Structure

Field Type Required Description
field string Yes Field name, using snake_case, e.g. create_time
operator string Yes Operator; see the supported operator list below
value string/number No Single value, used with eq/ne/gt/gte/lt/lte operators
values array No Array of values, used with in/not_in operators

Supported Operators

Operator Meaning Applies To Example Value
eq equals string/number/date "published"
ne not equals string/number/date "draft"
gt greater than number/date 100
gte greater than or equal number/date 100
lt less than number/date 1000
lte less than or equal number/date 1000
in contained in string/number ["a", "b"]
not_in not contained in string/number ["x", "y"]
exists field exists – null
not_exists field does not exist – null

Notes

sortFields Parameter Structure

Field Type Required Description
field string Yes Sort field
order string No ASC/DESC, defaults to DESC

aggregations Parameter Structure

Field Type Required Description
name string Yes Aggregation name (key of the result)
field string Yes Aggregation field
type string Yes Aggregation type: terms/range/date_histogram
size number No Number of buckets returned (terms only, default 10)
sortBy string No Sort field: count/value (terms only)
sortOrder string No Sort order: ASC/DESC (terms only)
ranges array No Range definitions (range only)
interval string No Time interval (date_histogram only)

interval Parameter

Value Description Use Case
1m per minute real-time monitoring
1h per hour daily trend analysis
1d per day daily reports
1w per week weekly reports
1M per month monthly reports
1y per year annual reports

Response Structure

Field Type Description
code string Status code
message string Response message
data object Response payload
data.items array List of search results
data.total number Total number of matched documents
data.aggs array List of aggregation results
data.took number Query time (milliseconds)
success boolean Whether the request succeeded

Response Example

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai"
  }'

1. Basic Search

Scenario: The simplest keyword search“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai'
})
});
const data = await response.json();

Python

import requests

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai'
}
)
data = response.json()

// Java
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tengence.com/v1/search"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer {YOUR_API_KEY}")
.POST(HttpRequest.BodyPublishers.ofString(
"{"query": "ai"}"
))
.build();

HttpResponse response = client.send(request,
HttpResponse.BodyHandlers.ofString());

// PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.tengence.com/v1/search");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer {YOUR_API_KEY}'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'query' => 'ai'
]));
$response = curl_exec($ch);
curl_close($ch);

// Go
package main

import (
"bytes"
"encoding/json"
"net/http"
)

func main() {
data := map[string]string{"query": "ai"}
jsonData, _ := json.Marshal(data)

req, _ := http.NewRequest("POST",
    "https://api.tengence.com/v1/search",
    bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer {YOUR_API_KEY}")

client := &http.Client{}
client.Do(req)

}


### 2. Paginated Search

**Scenario**: Fetch page 2 with 20 results per page```
curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "page": 2,
    "size": 20
  }'
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    page: 2,
    size: 20
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'page': 2,
        'size': 20
    }
)

3. 排序 – 价格降序

场景:按价格从高到低排序

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "sortFields": [{"field": "price", "order": "DESC"}]
  }'

3. Sorting – Price Descending

Scenario: Sort results from highest to lowest price“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
sortFields: [{ field: 'price', order: 'DESC' }]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'sortFields': [{'field': 'price', 'order': 'DESC'}]
}
)


---

### 4\. 多字段排序

**场景**:先按评分降序,再按评论数降序

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"sortFields": [
{"field": "rating", "order": "DESC"},
{"field": "review_count", "order": "DESC"}
]
}'


### 4. Multi-field Sorting

**Scenario**: First by rating descending, then by review count descending```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    sortFields: [
      { field: 'rating', order: 'DESC' },
      { field: 'review_count', order: 'DESC' }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'sortFields': [
            {'field': 'rating', 'order': 'DESC'},
            {'field': 'review_count', 'order': 'DESC'}
        ]
    }
)

5. 聚合 – 分类统计

场景:统计各分类下的内容数量

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "aggregations": [{
      "name": "by_category",
      "field": "category",
      "type": "terms",
      "size": 20,
      "sortBy": "count",
      "sortOrder": "DESC"
    }]
  }'

5. Aggregation – Category Counts

Scenario: Count the number of items under each category“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
aggregations: [{
name: 'by_category',
field: 'category',
type: 'terms',
size: 20,
sortBy: 'count',
sortOrder: 'DESC'
}]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'aggregations': [{
'name': 'by_category',
'field': 'category',
'type': 'terms',
'size': 20,
'sortBy': 'count',
'sortOrder': 'DESC'
}]
}
)


---

### 6\. 聚合 – 价格区间统计

**场景**:统计不同价格区间的商品分布

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"aggregations": [{
"name": "by_price_range",
"field": "price",
"type": "range",
"ranges": [
{"key": "low", "from": 0, "to": 100},
{"key": "medium", "from": 100, "to": 500},
{"key": "high", "from": 500, "to": 1000},
{"key": "luxury", "from": 1000}
]
}]
}'


### 6. Aggregation – Price Range

**Scenario**: Distribute products across different price ranges```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    aggregations: [{
      name: 'by_price_range',
      field: 'price',
      type: 'range',
      ranges: [
        { key: 'low', from: 0, to: 100 },
        { key: 'medium', from: 100, to: 500 },
        { key: 'high', from: 500, to: 1000 },
        { key: 'luxury', from: 1000 }
      ]
    }]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'aggregations': [{
            'name': 'by_price_range',
            'field': 'price',
            'type': 'range',
            'ranges': [
                {'key': 'low', 'from': 0, 'to': 100},
                {'key': 'medium', 'from': 100, 'to': 500},
                {'key': 'high', 'from': 500, 'to': 1000},
                {'key': 'luxury', 'from': 1000}
            ]
        }]
    }
)

7. 聚合 – 日期趋势(按天)

场景:查看最近30天的每日数量趋势

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "aggregations": [{
      "name": "daily_trend",
      "field": "create_time",
      "type": "date_histogram",
      "interval": "1d"
    }],
    "size": 0
  }'

7. Aggregation – Daily Date Trend

Scenario: View the daily count trend over the last 30 days“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
aggregations: [{
name: 'daily_trend',
field: 'create_time',
type: 'date_histogram',
interval: '1d'
}],
size: 0
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'aggregations': [{
'name': 'daily_trend',
'field': 'create_time',
'type': 'date_histogram',
'interval': '1d'
}],
'size': 0
}
)


---

### 8\. 聚合 – 月份趋势

**场景**:按月统计(12个月趋势)

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"aggregations": [{
"name": "monthly_trend",
"field": "create_time",
"type": "date_histogram",
"interval": "1M"
}]
}'


### 8. Aggregation – Monthly Trend

**Scenario**: Monthly statistics (12-month trend)```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    aggregations: [{
      name: 'monthly_trend',
      field: 'create_time',
      type: 'date_histogram',
      interval: '1M'
    }]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'aggregations': [{
            'name': 'monthly_trend',
            'field': 'create_time',
            'type': 'date_histogram',
            'interval': '1M'
        }]
    }
)

9. 多聚合组合 – 分类+品牌+价格

场景:搜索时,同时展示分类、品牌、价格区间筛选

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "page": 1,
    "size": 20,
    "aggregations": [
      {
        "name": "by_category",
        "field": "category",
        "type": "terms",
        "size": 10
      },
      {
        "name": "by_brand",
        "field": "brand",
        "type": "terms",
        "size": 10
      },
      {
        "name": "by_price_range",
        "field": "price",
        "type": "range",
        "ranges": [
          {"key": "under_1000", "to": 1000},
          {"key": "1000_3000", "from": 1000, "to": 3000},
          {"key": "3000_5000", "from": 3000, "to": 5000},
          {"key": "above_5000", "from": 5000}
        ]
      }
    ]
  }'

9. Combined Aggregations – Category + Brand + Price

Scenario: Show category, brand, and price-range filters together in one search“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
page: 1,
size: 20,
aggregations: [
{
name: 'by_category',
field: 'category',
type: 'terms',
size: 10
},
{
name: 'by_brand',
field: 'brand',
type: 'terms',
size: 10
},
{
name: 'by_price_range',
field: 'price',
type: 'range',
ranges: [
{ key: 'under_1000', to: 1000 },
{ key: '1000_3000', from: 1000, to: 3000 },
{ key: '3000_5000', from: 3000, to: 5000 },
{ key: 'above_5000', from: 5000 }
]
}
]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'page': 1,
'size': 20,
'aggregations': [
{
'name': 'by_category',
'field': 'category',
'type': 'terms',
'size': 10
},
{
'name': 'by_brand',
'field': 'brand',
'type': 'terms',
'size': 10
},
{
'name': 'by_price_range',
'field': 'price',
'type': 'range',
'ranges': [
{'key': 'under_1000', 'to': 1000},
{'key': '1000_3000', 'from': 1000, 'to': 3000},
{'key': '3000_5000', 'from': 3000, 'to': 5000},
{'key': 'above_5000', 'from': 5000}
]
}
]
}
)


---

### 10\. 过滤 – 精确匹配

**场景**:只显示已发布且属于特定分类的内容

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"filters": [
{"field": "status", "operator": "eq", "value": "published"},
{"field": "category", "operator": "eq", "value": "技术"}
]
}'


### 10. Filter – Exact Match

**Scenario**: Show only published items belonging to a specific category```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    filters: [
      { field: 'status', operator: 'eq', value: 'published' },
      { field: 'category', operator: 'eq', value: '技术' }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'filters': [
            {'field': 'status', 'operator': 'eq', 'value': 'published'},
            {'field': 'category', 'operator': 'eq', 'value': '技术'}
        ]
    }
)

11. 过滤 – 价格范围

场景:搜索价格在 1000-5000 之间的商品

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "filters": [
      {"field": "price", "operator": "gte", "value": 1000},
      {"field": "price", "operator": "lte", "value": 5000}
    ]
  }'

11. Filter – Price Range

Scenario: Search for products priced between 1,000 and 5,000“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
filters: [
{ field: 'price', operator: 'gte', value: 1000 },
{ field: 'price', operator: 'lte', value: 5000 }
]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'filters': [
{'field': 'price', 'operator': 'gte', 'value': 1000},
{'field': 'price', 'operator': 'lte', 'value': 5000}
]
}
)


---

### 12\. 过滤 – 日期范围

**场景**:只搜索 2025 年发布的内容

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"filters": [
{"field": "create_time", "operator": "gte", "value": "2025-01-01"},
{"field": "create_time", "operator": "lte", "value": "2025-12-31"}
]
}'


### 12. Filter – Date Range

**Scenario**: Search only for content published in 2025```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    filters: [
      { field: 'create_time', operator: 'gte', value: '2025-01-01' },
      { field: 'create_time', operator: 'lte', value: '2025-12-31' }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'filters': [
            {'field': 'create_time', 'operator': 'gte', 'value': '2025-01-01'},
            {'field': 'create_time', 'operator': 'lte', 'value': '2025-12-31'}
        ]
    }
)

13. 过滤 – 多值匹配 (IN)

场景:搜索多个分类下的内容

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "filters": [
      {"field": "category", "operator": "in", "values": ["机器学习", "深度学习", "自然语言处理"]}
    ]
  }'

13. Filter – Multi-value Match (IN)

Scenario: Search for content under multiple categories“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
filters: [
{ field: 'category', operator: 'in', values: ['机器学习', '深度学习', '自然语言处理'] }
]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'filters': [
{'field': 'category', 'operator': 'in', 'values': ['机器学习', '深度学习', '自然语言处理']}
]
}
)


---

### 14\. 过滤 – 排除值 (NOT IN)

**场景**:排除特定标签的内容

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"filters": [
{"field": "tags", "operator": "not_in", "values": ["广告", "推广"]}
]
}'


### 14. Filter – Exclude Values (NOT IN)

**Scenario**: Exclude content with specific tags```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    filters: [
      { field: 'tags', operator: 'not_in', values: ['广告', '推广'] }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'filters': [
            {'field': 'tags', 'operator': 'not_in', 'values': ['广告', '推广']}
        ]
    }
)

15. 过滤 – 大于/小于

场景:搜索评分大于 4.5 的内容

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "filters": [
      {"field": "rating", "operator": "gt", "value": 4.5}
    ]
  }'

15. Filter – Greater Than / Less Than

Scenario: Search for content with a rating above 4.5“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
filters: [
{ field: 'rating', operator: 'gt', value: 4.5 }
]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'filters': [
{'field': 'rating', 'operator': 'gt', 'value': 4.5}
]
}
)


---

### 16\. 综合过滤 – 电商商品筛选

**场景**:筛选商品,价格 2000-5000,品牌为指定值,状态为在售

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"page": 1,
"size": 20,
"filters": [
{"field": "price", "operator": "gte", "value": 2000},
{"field": "price", "operator": "lte", "value": 5000},
{"field": "brand", "operator": "in", "values": ["Apple", "华为", "HUAWEI"]},
{"field": "status", "operator": "eq", "value": "on_sale"}
],
"sortFields": [{"field": "sales_count", "order": "DESC"}]
}'


### 16. Combined Filters – E-commerce Product Filtering

**Scenario**: Filter products priced 2,000–5,000, of specified brands, and currently on sale```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    page: 1,
    size: 20,
    filters: [
      { field: 'price', operator: 'gte', value: 2000 },
      { field: 'price', operator: 'lte', value: 5000 },
      { field: 'brand', operator: 'in', values: ['Apple', '华为', 'HUAWEI'] },
      { field: 'status', operator: 'eq', value: 'on_sale' }
    ],
    sortFields: [{ field: 'sales_count', order: 'DESC' }]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'page': 1,
        'size': 20,
        'filters': [
            {'field': 'price', 'operator': 'gte', 'value': 2000},
            {'field': 'price', 'operator': 'lte', 'value': 5000},
            {'field': 'brand', 'operator': 'in', 'values': ['Apple', '华为', 'HUAWEI']},
            {'field': 'status', 'operator': 'eq', 'value': 'on_sale'}
        ],
        'sortFields': [{'field': 'sales_count', 'order': 'DESC'}]
    }
)

17. 高亮 – 指定高亮字段

场景:在标题和内容中高亮显示搜索词

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "highlightFields": ["title", "content"]
  }'

17. Highlighting – Specify Highlighted Fields

Scenario: Highlight the search term in titles and content“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
highlightFields: ['title', 'content']
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'highlightFields': ['title', 'content']
}
)


---

### 18\. 字段选择 – 限制搜索字段

**场景**:只在标题中搜索

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"searchFields": ["title"]
}'


### 18. Field Selection – Restrict Search Fields

**Scenario**: Search only within the title```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    searchFields: ['title']
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'searchFields': ['title']
    }
)

19. 字段选择 – 限制返回字段

场景:只返回 ID 和标题

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "includeFields": ["id", "title", "create_time"]
  }'

19. Field Selection – Restrict Returned Fields

Scenario: Return only the ID and title“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
includeFields: ['id', 'title', 'create_time']
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'includeFields': ['id', 'title', 'create_time']
}
)


---

### 20\. 电商场景 – 完整功能

**场景**:商品搜索,包含排序、高亮、聚合等完整功能

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"page": 1,
"size": 20,
"sortFields": [{"field": "sales_count", "order": "DESC"}],
"highlightFields": ["title", "description"],
"searchFields": ["title", "keywords", "brand"],
"includeFields": ["id", "title", "price", "brand", "sales_count"],
"aggregations": [
{
"name": "by_brand",
"field": "brand",
"type": "terms",
"size": 10,
"sortBy": "count",
"sortOrder": "DESC"
},
{
"name": "by_price",
"field": "price",
"type": "range",
"ranges": [
{"key": "budget", "to": 2000},
{"key": "mid_range", "from": 2000, "to": 5000},
{"key": "premium", "from": 5000}
]
}
]
}'


### 20. E-commerce Scenario – Full Features

**Scenario**: Product search with sorting, highlighting, aggregations, and more```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    page: 1,
    size: 20,
    sortFields: [{ field: 'sales_count', order: 'DESC' }],
    highlightFields: ['title', 'description'],
    searchFields: ['title', 'keywords', 'brand'],
    includeFields: ['id', 'title', 'price', 'brand', 'sales_count'],
    aggregations: [
      {
        name: 'by_brand',
        field: 'brand',
        type: 'terms',
        size: 10,
        sortBy: 'count',
        sortOrder: 'DESC'
      },
      {
        name: 'by_price',
        field: 'price',
        type: 'range',
        ranges: [
          { key: 'budget', to: 2000 },
          { key: 'mid_range', from: 2000, to: 5000 },
          { key: 'premium', from: 5000 }
        ]
      }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'page': 1,
        'size': 20,
        'sortFields': [{'field': 'sales_count', 'order': 'DESC'}],
        'highlightFields': ['title', 'description'],
        'searchFields': ['title', 'keywords', 'brand'],
        'includeFields': ['id', 'title', 'price', 'brand', 'sales_count'],
        'aggregations': [
            {
                'name': 'by_brand',
                'field': 'brand',
                'type': 'terms',
                'size': 10,
                'sortBy': 'count',
                'sortOrder': 'DESC'
            },
            {
                'name': 'by_price',
                'field': 'price',
                'type': 'range',
                'ranges': [
                    {'key': 'budget', 'to': 2000},
                    {'key': 'mid_range', 'from': 2000, 'to': 5000},
                    {'key': 'premium', 'from': 5000}
                ]
            }
        ]
    }
)

21. 内容搜索 – 完整功能

场景:内容搜索,按时间排序,支持日期趋势和来源聚合

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "page": 1,
    "size": 10,
    "sortFields": [{"field": "publish_time", "order": "DESC"}],
    "highlightFields": ["title", "summary"],
    "aggregations": [
      {
        "name": "by_date",
        "field": "publish_time",
        "type": "date_histogram",
        "interval": "1w"
      },
      {
        "name": "by_source",
        "field": "source",
        "type": "terms",
        "size": 20
      }
    ]
  }'

21. Content Search – Full Features

Scenario: Content search sorted by time, with date trends and source aggregation“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
page: 1,
size: 10,
sortFields: [{ field: 'publish_time', order: 'DESC' }],
highlightFields: ['title', 'summary'],
aggregations: [
{
name: 'by_date',
field: 'publish_time',
type: 'date_histogram',
interval: '1w'
},
{
name: 'by_source',
field: 'source',
type: 'terms',
size: 20
}
]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'page': 1,
'size': 10,
'sortFields': [{'field': 'publish_time', 'order': 'DESC'}],
'highlightFields': ['title', 'summary'],
'aggregations': [
{
'name': 'by_date',
'field': 'publish_time',
'type': 'date_histogram',
'interval': '1w'
},
{
'name': 'by_source',
'field': 'source',
'type': 'terms',
'size': 20
}
]
}
)


---

### 22\. 日志分析 – 完整功能

**场景**:日志分析搜索,按错误类型和服务名聚合

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ERROR",
"page": 1,
"size": 50,
"sortFields": [{"field": "timestamp", "order": "DESC"}],
"aggregations": [
{
"name": "errors_by_hour",
"field": "timestamp",
"type": "date_histogram",
"interval": "1h"
},
{
"name": "errors_by_code",
"field": "error_code",
"type": "terms",
"size": 20
},
{
"name": "errors_by_service",
"field": "service_name",
"type": "terms",
"size": 10
}
]
}'


### 22. Log Analysis – Full Features

**Scenario**: Log analysis search aggregated by error type and service name```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ERROR',
    page: 1,
    size: 50,
    sortFields: [{ field: 'timestamp', order: 'DESC' }],
    aggregations: [
      {
        name: 'errors_by_hour',
        field: 'timestamp',
        type: 'date_histogram',
        interval: '1h'
      },
      {
        name: 'errors_by_code',
        field: 'error_code',
        type: 'terms',
        size: 20
      },
      {
        name: 'errors_by_service',
        field: 'service_name',
        type: 'terms',
        size: 10
      }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ERROR',
        'page': 1,
        'size': 50,
        'sortFields': [{'field': 'timestamp', 'order': 'DESC'}],
        'aggregations': [
            {
                'name': 'errors_by_hour',
                'field': 'timestamp',
                'type': 'date_histogram',
                'interval': '1h'
            },
            {
                'name': 'errors_by_code',
                'field': 'error_code',
                'type': 'terms',
                'size': 20
            },
            {
                'name': 'errors_by_service',
                'field': 'service_name',
                'type': 'terms',
                'size': 10
            }
        ]
    }
)

23. 实时监控 – 分钟级统计

场景:按分钟统计最近一小时的实时数据

curl -X POST "https://api.tengence.com/v1/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR_API_KEY}" \
  -d '{
    "query": "ai",
    "aggregations": [{
      "name": "realtime_data",
      "field": "created_at",
      "type": "date_histogram",
      "interval": "1m"
    }],
    "sortFields": [{"field": "created_at", "order": "DESC"}]
  }'

23. Real-time Monitoring – Minute-level Stats

Scenario: Per-minute statistics of real-time data over the last hour“`
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
body: JSON.stringify({
query: 'ai',
aggregations: [{
name: 'realtime_data',
field: 'created_at',
type: 'date_histogram',
interval: '1m'
}],
sortFields: [{ field: 'created_at', order: 'DESC' }]
})
});

Python

response = requests.post(
'https://api.tengence.com/v1/search',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer {YOUR_API_KEY}'
},
json={
'query': 'ai',
'aggregations': [{
'name': 'realtime_data',
'field': 'created_at',
'type': 'date_histogram',
'interval': '1m'
}],
'sortFields': [{'field': 'created_at', 'order': 'DESC'}]
}
)


---

### 24\. 综合业务场景

**场景**:搜索,结合过滤、排序、高亮、聚合等全部功能

curl -X POST "https://api.tengence.com/v1/search"
-H "Content-Type: application/json"
-H "Authorization: Bearer {YOUR_API_KEY}"
-d '{
"query": "ai",
"page": 1,
"size": 20,
"filters": [
{"field": "price", "operator": "gte", "value": 2000},
{"field": "price", "operator": "lte", "value": 5000},
{"field": "brand", "operator": "in", "values": ["Apple", "华为"]},
{"field": "status", "operator": "eq", "value": "on_sale"}
],
"sortFields": [
{"field": "sales_count", "order": "DESC"},
{"field": "rating", "order": "DESC"}
],
"highlightFields": ["title", "description"],
"searchFields": ["title", "keywords", "brand"],
"includeFields": ["id", "title", "price", "brand", "sales_count", "rating"],
"aggregations": [
{
"name": "by_brand",
"field": "brand",
"type": "terms",
"size": 10
},
{
"name": "by_price_range",
"field": "price",
"type": "range",
"ranges": [
{"key": "budget", "to": 3000},
{"key": "mid_range", "from": 3000, "to": 4000},
{"key": "premium", "from": 4000}
]
}
]
}'


### 24. Comprehensive Business Scenario

**Scenario**: Search combining filtering, sorting, highlighting, and aggregations```
// JavaScript
const response = await fetch('https://api.tengence.com/v1/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {YOUR_API_KEY}'
  },
  body: JSON.stringify({
    query: 'ai',
    page: 1,
    size: 20,
    filters: [
      { field: 'price', operator: 'gte', value: 2000 },
      { field: 'price', operator: 'lte', value: 5000 },
      { field: 'brand', operator: 'in', values: ['Apple', '华为'] },
      { field: 'status', operator: 'eq', value: 'on_sale' }
    ],
    sortFields: [
      { field: 'sales_count', order: 'DESC' },
      { field: 'rating', order: 'DESC' }
    ],
    highlightFields: ['title', 'description'],
    searchFields: ['title', 'keywords', 'brand'],
    includeFields: ['id', 'title', 'price', 'brand', 'sales_count', 'rating'],
    aggregations: [
      {
        name: 'by_brand',
        field: 'brand',
        type: 'terms',
        size: 10
      },
      {
        name: 'by_price_range',
        field: 'price',
        type: 'range',
        ranges: [
          { key: 'budget', to: 3000 },
          { key: 'mid_range', from: 3000, to: 4000 },
          { key: 'premium', from: 4000 }
        ]
      }
    ]
  })
});
# Python
response = requests.post(
    'https://api.tengence.com/v1/search',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer {YOUR_API_KEY}'
    },
    json={
        'query': 'ai',
        'page': 1,
        'size': 20,
        'filters': [
            {'field': 'price', 'operator': 'gte', 'value': 2000},
            {'field': 'price', 'operator': 'lte', 'value': 5000},
            {'field': 'brand', 'operator': 'in', 'values': ['Apple', '华为']},
            {'field': 'status', 'operator': 'eq', 'value': 'on_sale'}
        ],
        'sortFields': [
            {'field': 'sales_count', 'order': 'DESC'},
            {'field': 'rating', 'order': 'DESC'}
        ],
        'highlightFields': ['title', 'description'],
        'searchFields': ['title', 'keywords', 'brand'],
        'includeFields': ['id', 'title', 'price', 'brand', 'sales_count', 'rating'],
        'aggregations': [
            {
                'name': 'by_brand',
                'field': 'brand',
                'type': 'terms',
                'size': 10
            },
            {
                'name': 'by_price_range',
                'field': 'price',
                'type': 'range',
                'ranges': [
                    {'key': 'budget', 'to': 3000},
                    {'key': 'mid_range', 'from': 3000, 'to': 4000},
                    {'key': 'premium', 'from': 4000}
                ]
            }
        ]
    }
)

FAQ

Q: How do I get an API Key?

Sign in to the Tengence Console (https://console.tengence.com) and copy the API Key from the Application Details page.


Q: What date formats are supported?

Date fields support several formats:


Q: How do I configure pagination?

Use the page and size parameters:


Q: How do I combine multiple filter conditions?

Add multiple filter objects to the filters array. Multiple conditions are combined with a logical AND.


Q: How are aggregation results sorted?

For terms aggregations, use the sortBy and sortOrder parameters:


Q: What should I do if no results are returned?

Check the following:

  1. Whether the search keyword is correct
  2. Whether the index contains relevant data
  3. Whether the filter conditions are too strict
  4. Whether the field names are correct (use snake_case)

Q: How do I restrict the search field scope?

Use the searchFields parameter to specify the list of fields to search.


Q: How do I return only the fields I need?

Use the includeFields parameter to specify the list of fields to return.


Related Resources


Next: Tengence Data Center User Guide: API Push, MySQL, and Behavior Datasets →
Consult
QR code

WeCom