Product docs
- Getting started
- Platform and account
- Products
- Product Overview
- Tengence Search
- Product Overview
- Use cases: which businesses Tengence Search fits
- Getting started
- Search Setup: App, Dataset, Index, First Query
- OpenSearch Spring Boot Starter Integration
- Elasticsearch Spring Boot Starter Integration
- Guides
- Index Concepts and Configuration Guide
- Index Schema Reference
- Search Ranking and Weighting Configuration
- Ranking Factors and Functions Reference
- Search Suggestions and Intervention Rules
- Developer reference
- Search API Reference
- Search API Integration and Examples
- Search Widget Integration
- Operations and support
- Search Operations and Monitoring
- Search Troubleshooting
- Query Rules and Query Intervention
- Search Log Collection Policy
- Query Understanding Configuration
- Tengence GEO
- Tengence Recommendation
- Tengence Insight
- Data Integration
- Integration and API
- Solutions
- Concepts and metrics
Search API Integration and Examples
Integration flow and runnable examples for the Tengence Search API: credentials, first request, fields, filters, sorting, pagination, aggregations and error ha…
This guide follows one executable path: obtain credentials, send the first request, combine filters, sorting, pagination and aggregations, then check the integration before going live. The sample data comes from Aurora-Living-Product-Search (app ID 11942244).
Before you start
You need three things: the app ID from the console, an API key, and the real field names in your index. The app ID confirms which app a request reaches. The API key stays on the server. Do not copy field names from the examples; query the field endpoint first to see what your index actually contains.

In the console, open Tengence Search → Apps → App Details and find Integration Guide. The API key is hidden by default; use the eye icon to reveal it. Next to it are API Integration, Page Component Integration and API Debug. This guide uses API Integration and API Debug.
Authentication: two modes, never mixed
There is one search endpoint: POST https://api.tengence.com/v1/search. The body is JSON and the credential goes in the Authorization header. There are two credential types: the API key for direct backend calls, and an access token issued by your backend for frontend calls. Never send the API key to a browser.
Backend: call with the API key
Send Authorization: Bearer <API key> from your server. API keys start with sk-; the gateway uses that prefix to identify an app credential and injects the app identity automatically. The client does not need to send the app ID.

export TENGENCE_API_KEY="sk-your-api-key"
curl -X POST "https://api.tengence.com/v1/search" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENGENCE_API_KEY" \
-d '{
"query": "table",
"page": 1,
"size": 3
}'
Frontend: issue an access token from your backend
If the search request must originate in a browser, do not put the API key there. Your backend calls the token issue endpoint with the API key, receives a short-lived pair, and passes only the accessToken to the frontend. The refreshToken stays on the backend for renewal and revocation.

Issue request:
curl -X POST "https://api.tengence.com/v1/app/auth/token/issue" \
-H "Content-Type: application/json" \
-d '{
"apiKey": "sk-your-api-key",
"deviceId": "web-device-or-session-id",
"deviceType": "web"
}'
Real response (tokens truncated):
{
"code": "SUCCESS",
"message": "Operation successful",
"data": {
"accessToken": "eyJ...",
"refreshToken": "eyJ...",
"accessExpAt": 1796364665493,
"refreshExpAt": 1796968565493,
"appId": "11942244",
"tokenType": "Bearer"
}
}
The access token lives about 15 minutes and the refresh token about 7 days; always use accessExpAt and refreshExpAt from the response. The frontend calls search with the access token exactly the way the backend uses the API key, only with a different Bearer value. Before expiry, the backend calls POST /v1/app/auth/token/refresh for a new pair. On logout or suspected credential leak, call POST /v1/app/auth/token/revoke to revoke the refresh token.
Your first search request
A single query is enough. page defaults to 1 and size to 10; this example sets size to 3 so the response shape is easy to read.
curl -X POST "https://api.tengence.com/v1/search" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENGENCE_API_KEY" \
-d '{"query":"table","page":1,"size":3}'
Real response (two items kept, took in milliseconds):
{
"code": "SUCCESS",
"message": "Operation successful",
"data": {
"items": [
{
"item_id": "AL-TBL-026",
"id": "AL-TBL-026",
"title": "nook side table",
"description": "compact side table with a rounded top and a lower shelf for books. fits beside armchairs and beds.",
"category_name": "side tables",
"price": "249",
"rating": "4.8"
},
{
"item_id": "AL-TBL-422",
"id": "AL-TBL-422",
"title": "fjord oak dining table",
"description": "solid oak dining table for six, finished with a matte water-based lacquer. trestle base leaves clear space at each end.",
"category_name": "dining tables",
"price": "1299",
"rating": "4.8"
}
],
"total": 4,
"aggs": [],
"took": 196
}
}
The envelope has only code, message and data; there is no success field. Check code == "SUCCESS" instead of treating HTTP 200 as business success. data.total is the total match count, not the current page size. data.took is server time.
Confirm field names first
The title, price and category_name fields belong to the demo index; your index may differ. Query the field list before integration:
curl "https://api.tengence.com/v1/search/index/fields" \
-H "Authorization: Bearer $TENGENCE_API_KEY"
{
"code": "SUCCESS",
"message": "Operation successful",
"data": [
{"indexFieldName": "category_name", "semanticType": "CATEGORY_NAME", "processType": "ANALYZED_TEXT"},
{"indexFieldName": "description", "semanticType": "DESCRIPTION", "processType": "ANALYZED_TEXT"},
{"indexFieldName": "item_id", "semanticType": "ID", "processType": "KEYWORD"},
{"indexFieldName": "price", "semanticType": "PRICE", "processType": "NUMERIC"},
{"indexFieldName": "rating", "semanticType": "RATING", "processType": "NUMERIC"},
{"indexFieldName": "title", "semanticType": "TITLE", "processType": "ANALYZED_TEXT"}
]
}
processType determines how a field can be used. KEYWORD suits exact matching and terms aggregations. ANALYZED_TEXT is tokenized, so exact phrase filters and terms aggregations behave differently. NUMERIC suits range filters and range aggregations. Wrong field names or types make filters and sorting fail or return empty results.
Common examples
Restrict search fields
By default the query searches every searchable field. Use searchFields to search titles only:
-d '{"query":"table","searchFields":["title"],"size":1}'
For the same query table, restricting to title returns 3 matches and restricting to description returns 4. An unknown field does not raise an error; it returns 0 results. Always validate field names with the field endpoint.
Trim response fields
includeFields keeps only the fields the UI needs and reduces payload size:
-d '{"query":"table","size":1,"includeFields":["title"]}'
{
"title": "nook side table",
"id": "AL-TBL-026"
}
Even when only title is requested, id is still returned for detail links or deduplication. Do not assume includeFields can remove id.
Highlight matched terms
With highlightFields, matched terms are written back into the original field wrapped in <em>. There is no separate highlight object:
-d '{"query":"table","size":1,"highlightFields":["title","description"]}'
{
"title": "nook side <em>table</em>",
"description": "compact side <em>table</em> with a rounded top and a lower shelf for books. fits beside armchairs and beds."
}
Escape the HTML before rendering, or allow only the <em> tag. Never inject the whole description into innerHTML unescaped.
Exact filters and numeric ranges
Filter by product ID. item_id is a KEYWORD field, so eq reliably returns one item:
-d '{"query":"table","filters":[{"field":"item_id","operator":"eq","value":"AL-TBL-318"}]}'
{
"item_id": "AL-TBL-318",
"title": "halo marble coffee table",
"price": "649"
}
Use in for multiple IDs. Multiple filters are combined with AND:
-d '{"query":"table","filters":[{"field":"item_id","operator":"in","values":["AL-TBL-026","AL-TBL-318","AL-LGT-603"]}]}'
Filter a price range with two conditions:
-d '{"query":"table","filters":[{"field":"price","operator":"gte","value":600},{"field":"price","operator":"lte","value":1000}]}'
This returns one real match: AL-TBL-318 at "649". price is a string in the response, but filters accept either a number or a numeric string; convert to a number before doing arithmetic.
category_name is tokenized. eq "coffee tables" as a multi-word phrase returns 0, while eq "coffee" returns 1. When you need an exact full category string, prefer a KEYWORD field such as item_id, or re-filter on the original category_name value in the client.
Sorting
sortFields[].order must be uppercase ASC or DESC. Lowercase asc returns 400 BAD_REQUEST; it is not ignored.
-d '{"query":"a","size":3,"sortFields":[{"field":"price","order":"ASC"}],"includeFields":["price"]}'
{"code":"SUCCESS","data":{"items":[{"price":"79","id":"AL-DEC-805"},{"price":"119","id":"AL-DEC-067"},{"price":"129","id":"AL-STO-014"}]}}
Changing ASC to DESC returns 1899, 1599, 1499 for the same query. The sort field must exist in the field list; an unknown sort field may return an empty result.
Pagination
-d '{"query":"table","page":2,"size":3}'
Page 1 returns 3 items; page 2 returns the remaining item, AL-LGT-603, while total stays 4. size supports 1–100; a value above 100 falls back to the default 10 instead of raising an error. page starts at 1. Do not rely on a fixed fallback beyond the last page; compute page counts from total and size.
Range aggregation
Aggregate prices into buckets. The result is an array in data.aggs:
-d '{
"query":"table",
"size":1,
"aggregations":[
{"name":"by_price","type":"range","field":"price","ranges":[
{"key":"under_500","to":500},
{"key":"500_1500","from":500,"to":1500}
]}
]
}'
{
"name": "by_price",
"field": "price",
"type": "range",
"items": [
{"value":"under_500","label":"under_500","count":2,"from":0.0,"to":500.0},
{"value":"500_1500","label":"500_1500","count":2,"from":500.0,"to":1500.0}
]
}
terms aggregations work only on KEYWORD fields. On an ANALYZED_TEXT field such as category_name, a terms aggregation returned total: 0 and an empty aggs array. Check the field type first, or use a range aggregation instead.
A range bucket with only from and no to currently returns count: 0. If you need an open upper bound, pass an explicit large to.
Composite queries: filters, sorting, highlighting, and aggregations
Combine filters, sortFields, highlightFields, searchFields, includeFields, and aggregations in one request. The example searches products priced 400–1400 with a rating of at least 4.7, sorts by price descending then rating descending, highlights the title and description, and returns price and rating buckets.
curl -X POST https://api.tengence.com/v1/search \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENGENCE_API_KEY" \
-d '{
"query": "table",
"page": 1,
"size": 3,
"filters": [
{
"field": "price",
"operator": "gte",
"value": 400
},
{
"field": "price",
"operator": "lte",
"value": 1400
},
{
"field": "rating",
"operator": "gte",
"value": 4.7
}
],
"sortFields": [
{
"field": "price",
"order": "DESC"
},
{
"field": "rating",
"order": "DESC"
}
],
"highlightFields": [
"title",
"description"
],
"searchFields": [
"title",
"description"
],
"includeFields": [
"item_id",
"title",
"price",
"rating",
"category_name",
"description"
],
"aggregations": [
{
"name": "price_bands",
"field": "price",
"type": "range",
"ranges": [
{
"key": "0_500",
"from": 0,
"to": 500
},
{
"key": "500_1000",
"from": 500,
"to": 1000
},
{
"key": "1000_1500",
"from": 1000,
"to": 1500
}
]
},
{
"name": "rating_bands",
"field": "rating",
"type": "range",
"ranges": [
{
"key": "4.6_4.8",
"from": 4.6,
"to": 4.8
},
{
"key": "4.8_5.0",
"from": 4.8,
"to": 5.0
}
]
}
]
}'
Only the first item is shown; the other two are omitted.
{
"code": "SUCCESS",
"message": "Operation successful",
"data": {
"items": [
{
"category_name": "dining tables",
"item_id": "AL-TBL-422",
"price": "1299",
"rating": "4.8",
"description": "solid oak dining <em>table</em> for six, finished with a matte water-based lacquer. trestle base leaves clear space at each end.",
"id": "AL-TBL-422",
"title": "fjord oak dining <em>table</em>"
}
],
"total": 3,
"aggs": [
{
"name": "price_bands",
"field": "price",
"type": "range",
"items": [
{
"value": "0_500",
"label": "0_500",
"count": 1,
"from": 0.0,
"to": 500.0
},
{
"value": "500_1000",
"label": "500_1000",
"count": 1,
"from": 500.0,
"to": 1000.0
},
{
"value": "1000_1500",
"label": "1000_1500",
"count": 1,
"from": 1000.0,
"to": 1500.0
}
]
},
{
"name": "rating_bands",
"field": "rating",
"type": "range",
"items": [
{
"value": "4.6_4.8",
"label": "4.6_4.8",
"count": 1,
"from": 4.6,
"to": 4.8
},
{
"value": "4.8_5.0",
"label": "4.8_5.0",
"count": 2,
"from": 4.8,
"to": 5.0
}
]
}
],
"took": 340
}
}
Filters are combined with AND. Sorts apply in array order. Aggregations are computed over the filtered result set. The three matched products fall into three price buckets and two rating buckets.
If a field is listed in highlightFields but removed by includeFields, it is not returned at all, so the highlighted text is invisible. Keep every highlighted field in the response fields.
To restrict to a specific item set, add an item_id in filter. item_id is a KEYWORD field, so exact matching works.
{"field":"item_id","operator":"in","values":["AL-TBL-026","AL-TBL-318","AL-TBL-422"]}
Errors and edge cases
Authentication errors are the clearest HTTP 4xx cases:
{"code":"MISSING_CREDENTIAL","message":"Please provide a valid credential","data":null}
{"code":"API_KEY_INVALID","message":"Invalid API key, please check and retry","data":null}
Both are HTTP 401. A missing Authorization header returns MISSING_CREDENTIAL; a wrong or expired key returns API_KEY_INVALID.
The search endpoint is permissive about some bad inputs. An empty query, a missing query, an unknown searchFields field, an unknown filter field, or an invalid filter operator can all return HTTP 200 with code: SUCCESS, either with 0 results or with the filter ignored. A lowercase sort order, by contrast, returns 400 BAD_REQUEST. Validate on the client before sending: require a non-empty query, take field names from the field endpoint, use uppercase sort order, and make sure each filter can match at least one document.
For troubleshooting, keep the x-tengence-request-id response header. If the client sends the same header, the response echoes that value, which makes correlation with server logs easier.
Pre-launch checklist
- Confirm field names and
processTypewith the field endpoint; do not copy the demo fields. - Keep the API key in backend environment variables, out of frontend bundles and Git.
- Use access tokens in the frontend; keep
refreshTokenon the backend and handle renewal and revocation. - Judge business success by
code; HTTP 200 is not enough. - Handle the fact that
includeFieldsalways keepsid. - Escape highlighted HTML before rendering.
- Compute pagination from
totalandsize; do not rely on out-of-range fallback behavior. - Record
x-tengence-request-idfor support.
The full parameter, response and error contract is in the Search API reference. App, dataset and index setup is in Search Setup.
On this page
- Before you start
- Authentication: two modes, never mixed
- Backend: call with the API key
- Frontend: issue an access token from your backend
- Your first search request
- Confirm field names first
- Common examples
- Restrict search fields
- Trim response fields
- Highlight matched terms
- Exact filters and numeric ranges
- Sorting
- Pagination
- Range aggregation
- Composite queries: filters, sorting, highlighting, and aggregations
- Errors and edge cases
- Pre-launch checklist