Buscar en la base de conocimientos por full-text, vector o híbrido.
Knowledge base
POST /v1/knowledge/search
Search the knowledge base by full-text, vector, or hybrid.
POST
Buscar en la base de conocimientos por full-text, vector o híbrido.
Runs a query over the indexed chunks of the knowledge base. Supports three search modes — pick the one that best fits the user’s query:
Results are grouped by
| Mode | When to use it | How it works internally |
|---|---|---|
full | Exact terms, keywords, numbers, IDs. | MongoDB text index over page_content with Spanish stemming. |
vector | Natural language questions, synonyms, paraphrasing. | MongoDB Atlas Vector Search with text-embedding-3-small embeddings. |
hybrid | Sensible default when you don’t know what kind of query is coming. | Runs both in parallel, normalizes scores, and combines them with a 0.6 vector / 0.4 full-text weight. |
node_id (the same document appears only once even if several chunks match) and sorted by descending score.
Endpoint
Required scope
knowledge:query
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer kbai_pk_<token> |
Content-Type | Yes | application/json |
Body
| Field | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search text. |
mode | string | Yes | full, vector, or hybrid. |
top_k | number | No | Max number of results, between 1 and 25. Default 5. |
node_ids | string[] | No | Restrict the search to these node_id values (folders or documents). Useful to scope to a domain within the tree. Max 100 ids. |
Example request
Response
200 OK
| Field | Type | Description |
|---|---|---|
mode | string | Mode applied (same as in the request). |
results[].node_id | string | ObjectId of the document in the knowledge base. Useful for cross-referencing with GET /v1/knowledge/tree. |
results[].title | string | Document title (no full content). |
results[].snippet | string | Fragment of the highest-scoring chunk, truncated to ~320 characters. |
results[].score | number | Normalized score. The scale depends on the mode: in vector and hybrid it’s in [0,1]; in full it’s the raw Mongo textScore. Only comparable between items in the same response. |
results[].source | string | vector or full, depending on which engine produced the top-scoring match (in hybrid it indicates which one won after combination). |
400 / 401 / 403 / 429
400 BAD_REQUEST:queryempty,modenot supported, ornode_idswith invalid format.403 FORBIDDENwithcode: INSUFFICIENT_SCOPE: the PAT doesn’t haveknowledge:query.
Authorizations
Personal Access Token con prefijo kbai_pk_. Generar desde el portal con permiso developer.manage_tokens.
Body
application/json
Texto de búsqueda.
Example:
"¿cómo cancelar suscripción?"
Modo de búsqueda: full (full-text), vector (semántica) o hybrid (combinación con re-ranking).
Available options:
full, hybrid, vector Example:
"hybrid"
Cantidad máxima de resultados (1-25).
Example:
5
Limita la búsqueda a estos node ids (carpetas o documentos).