Overview
The/siaa/enrutar endpoint simulates the document routing process without actually extracting fragments or calling the AI model. It shows which documents would be selected for a given query and why, making it essential for debugging retrieval issues.
Endpoint
Parameters
The query/question to test against the routing algorithmExample:
¿Cuál es la periodicidad del reporte SIERJU?Response
The original query string
Whether the query contains specific document references (e.g., “PSAA16”, “Acuerdo”, “Circular”). When
true, only 1 document is returned; otherwise, up to MAX_DOCS_CONTEXTO documents are returned.Maximum number of documents that would be used for this query (1 for specific doc queries, 2 for general queries in the default configuration)
List of documents selected by the routing algorithm, in ranked order
Example
Request
Response
Request with Specific Document Reference
Response
Use Cases
Debugging Wrong Document Selection
When users report that the system is returning answers from the wrong document:docs_encontrados. If not, check:
- Keywords for the expected document (
/siaa/keywords/<doc>) - Term density for query terms (
/siaa/densidad/<term>) - Manual keyword configuration in
KEYWORDS_MANUALES
Testing Query Variations
Compare how different phrasings affect document selection:Validating Multi-Level Routing
The routing algorithm uses three levels:- TF-IDF keywords (automatic + manual) — weight 2.0
- Term density across documents — weight 1.0
- Filename token matching — weight 1.5
Verifying Specific Document Detection
The system limits results to 1 document when queries mention specific documents:Notes
- The routing algorithm uses a multi-level scoring system combining TF-IDF, term density, and filename matching
- Specific document patterns include:
psaa,pcsja,acuerdo,circular,resolución,decreto - The
MAX_DOCS_CONTEXTOconfiguration (default: 2) determines the maximum documents for general queries - Documents are scored but this endpoint doesn’t show the actual scores (check server logs with
[ENRUTADOR]prefix for score details) - Query expansion happens automatically for temporal queries (“cuándo” → adds “periodicidad”, “plazo”, “hábil”)