TengenceTengence
Product docs

Search API Reference

Request and response contract for the Tengence Search API: endpoints, auth, parameters, filters, sorting, aggregations, response and errors.

This page is the request and response contract for Tengence Search’s public HTTP API, organized as endpoints, authentication, request parameters, filtering/sorting/aggregation, response, and error codes. For setup steps and runnable examples, see Search API Integration and Examples.

If the API changes, the live response wins.

Endpoints

All endpoints use https://api.tengence.com as the base URL and exchange JSON.

Method and path Purpose Auth
POST /v1/search Search with filters, sorting, pagination, field selection, highlighting and aggregations API key or access token
GET /v1/search/index/fields List field names, semantic types and process types for the current index API key or access token
GET /v1/search/suggest?query=... Query suggestions with scores API key or access token
GET /v1/search/hot-words?size=... Hot search terms API key or access token
GET /v1/search/hint-words?size=... Hint terms API key or access token
POST /v1/app/auth/token/issue Issue an access token and refresh token with an API key API key
POST /v1/app/auth/token/refresh Exchange a refresh token for a new pair Refresh token
POST /v1/app/auth/token/revoke Revoke a refresh token Refresh token

Authentication

Request headers:

Content-Type: application/json
Authorization: Bearer <API key or access token>

API keys start with sk- and are for direct server calls. Access tokens are issued by the token issue endpoint and are for frontend calls. The gateway identifies the app from the credential and injects X-Tengence-App-Id; the client does not send the app ID itself. Never expose the API key in a browser, a frontend bundle or a public repository.

Issue an access token:

curl -X POST "https://api.tengence.com/v1/app/auth/token/issue" \
  -H "Content-Type: application/json" \
  -d '{"apiKey":"sk-...","deviceId":"web-session-1","deviceType":"web"}'

Response data fields:

Field Type Description
accessToken string Short-lived token for search calls
refreshToken string Stored on the backend for renewal or revocation
accessExpAt number Access token expiry, millisecond timestamp
refreshExpAt number Refresh token expiry, millisecond timestamp
appId string App ID
tokenType string Always Bearer

In production testing, the access token expired in about 15 minutes and the refresh token in about 7 days. To refresh, send {"refreshToken":"..."}; the response contains a new pair. Replace the old refresh token with the new one. To revoke, send the same body; success returns data: null.

Search request

Body for POST /v1/search:

Parameter Type Default Description
query string none Query text. An empty string or missing query currently returns 0 results without an error
page number 1 Page number, starting at 1
size number 10 Page size, 1–100; values above 100 fall back to 10
searchFields string[] all searchable fields Restrict the search to these fields
includeFields string[] all fields Return only these fields; id is always kept
highlightFields string[] none Wrap matches in <em> inside the original fields
sortFields object[] relevance Each item is {field, order}; order must be ASC or DESC
filters object[] none Filter conditions; multiple conditions are ANDed
aggregations object[] none Aggregation definitions

Minimal request:

{"query":"table","page":1,"size":3}

Filtering

A single filter:

{"field":"price","operator":"gte","value":600}

field must be a real field name from the field endpoint. value is used for single-value operators and values for multi-value operators. Multiple filters are ANDed.

Operators currently working:

Operator Usage Description
eq {"field":"item_id","operator":"eq","value":"AL-TBL-318"} Equality; stable on KEYWORD, token-based on ANALYZED_TEXT
in {"field":"item_id","operator":"in","values":["A","B"]} Match any of the values
gt / gte {"field":"price","operator":"gte","value":600} Numeric greater than / greater than or equal
lt / lte {"field":"price","operator":"lte","value":1000} Numeric less than / less than or equal

Current limitation: ne, not_in, exists and not_exists had no effect in production testing and returned unfiltered results. Invalid operators were also ignored. If you need those semantics, filter on the client or wait for a server fix.

ANALYZED_TEXT fields such as category_name are tokenized. eq "coffee tables" as a multi-word phrase returns 0, while eq "coffee" matches one item. For exact full-string matching, use a KEYWORD field such as item_id, or re-filter on the original value in the client.

Sorting

{"sortFields":[{"field":"price","order":"ASC"}]}

order must be uppercase: ASC or DESC. Lowercase asc / desc returns HTTP 400 with BAD_REQUEST. The field must exist; an unknown field may return an empty result. Confirm fields with the field endpoint before shipping.

Field selection and highlighting

includeFields keeps only the requested fields, but id is always returned:

{"query":"table","size":1,"includeFields":["title"]}
{"title":"nook side table","id":"AL-TBL-026"}

highlightFields writes matched terms back into the original field wrapped in <em>; there is no separate highlight object:

{"query":"table","size":1,"highlightFields":["title"]}
{"title":"nook side <em>table</em>","id":"AL-TBL-026"}

Escape the HTML before rendering, or allow only the <em> tag.

Aggregations

Aggregation definition:

{
  "name":"by_price",
  "type":"range",
  "field":"price",
  "ranges":[
    {"key":"under_500","to":500},
    {"key":"500_1500","from":500,"to":1500}
  ]
}

The response data.aggs is an array:

[
  {
    "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}
    ]
  }
]

range suits NUMERIC fields. terms works only on KEYWORD fields; on an ANALYZED_TEXT field, terms returned total: 0 and an empty aggs array. Check the field type first, or use a range aggregation.

Response

A successful response has exactly three layers:

{
  "code":"SUCCESS",
  "message":"Operation successful",
  "data":{
    "items":[],
    "total":0,
    "aggs":[],
    "took":0
  }
}

There is no success field. Judge business success by code == "SUCCESS", not by the HTTP status alone.

data fields:

Field Type Description
items object[] Documents on the current page
total number Total match count, not the current page size
aggs object[] Aggregation results; an empty array when no aggregation was sent
took number Server time in milliseconds

Item fields depend on the index. The demo index returns:

Field Type Description
item_id string Business unique identifier
id string Document ID; identical to item_id in the demo index, always returned
title string Title
description string Description
category_name string Category name
price string Price as a string
rating string Rating as a string

Numeric fields may be strings in the response; convert before doing arithmetic.

Supporting endpoints

Field list

GET /v1/search/index/fields
{"code":"SUCCESS","data":[
  {"indexFieldName":"item_id","semanticType":"ID","processType":"KEYWORD"},
  {"indexFieldName":"title","semanticType":"TITLE","processType":"ANALYZED_TEXT"},
  {"indexFieldName":"price","semanticType":"PRICE","processType":"NUMERIC"}
]}

Suggestions

GET /v1/search/suggest?query=ta&size=3
{"code":"SUCCESS","data":{"suggestions":[
  {"text":"table nook","score":0.17},
  {"text":"table halo","score":0.17},
  {"text":"table fjord","score":0.17}
]}}

A missing query returns HTTP 400 with MISSING_PARAMETER.

Hot words and hint words

GET /v1/search/hot-words?size=3
GET /v1/search/hint-words?size=3

data is an array of strings, for example ["table","dining","sheet"].

Error codes

HTTP code Scenario
200 SUCCESS Request completed; zero results is still success
400 BAD_REQUEST Malformed body or invalid enum, such as lowercase sort order
400 MISSING_PARAMETER Missing a required query parameter, such as suggest without query
400 VALIDATION_ERROR Token endpoint missing apiKey / refreshToken
401 MISSING_CREDENTIAL No authentication header
401 API_KEY_INVALID Invalid API key
500 AUTH_TOKEN_REVOKED Refresh token already revoked; issue a new one

Refreshing with a revoked refresh token returned HTTP 500 with AUTH_TOKEN_REVOKED in production. Parse the response body code rather than relying on HTTP status alone.

Known limitations

  • An empty query, an unknown searchFields field, an unknown filter field, or an invalid filter operator can return HTTP 200 with SUCCESS, either with zero results or with the condition ignored.
  • ne, not_in, exists and not_exists currently have no effect and return unfiltered results.
  • terms aggregation on an ANALYZED_TEXT field produces total=0 and aggs=[].
  • GET /v1/search/{id} currently returns an empty object {} for existing documents. Do not treat it as a stable contract; use filters with item_id when you need a single document.
  • 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.

For troubleshooting, record the x-tengence-request-id response header; when the client sends the same header, the response echoes it. Setup steps and full examples are in Search API Integration and Examples.

On this page