Semantic Search
text-searchRank a list of documents by semantic similarity to a query.
POST a query and a documents array. The response is {results[], query, total_documents}, where each result has {rank, text, score, index}.
POST
/v1/proxy/text-searchSemantic search (synchronous)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query | string | required | The search query. |
documents | array<string> | required | The candidate documents to rank. |
curl -X POST https://api.cn8.io/v1/proxy/text-search \
-H "X-API-Key: <cn8_api_key>" \
-H "Content-Type: application/json" \
-d '{"query":"your text here","documents":["value"]}'Response
{
"status": "success",
"data": {
"results": [
{ "rank": 1, "text": "Tesla makes electric vehicles", "score": 0.7204, "index": 0 },
{ "rank": 2, "text": "Lithium batteries power EVs", "score": 0.4809, "index": 2 }
],
"query": "electric cars",
"total_documents": 3
}
}
Keeping only the top matches
All documents are returned ranked. To keep just the top N, slice the results array in your own code.