Skip to main content

Route Handlers Reference

hlquery route handling has three layers:

  1. src/api/httproutes.cpp normalizes the request path and maps it to a RouteAction.
  2. src/api/httpserver.cpp performs authentication, readiness checks, sync/write gates, and dispatch.
  3. SearchAPI handlers implement the endpoint behavior across src/api/*.cpp.

Use Complete API Reference for the full route table. This page focuses on implementation ownership and handler behavior.

Route Resolver

ResolveHttpRoute(const HttpRequest &Request) is the source of truth for route matching.

Important behavior:

  • Query strings are ignored during route matching.
  • One trailing slash is ignored.
  • Routes are method-specific.
  • Collection routes are parsed by path segments, not by broad string prefixes.
  • /collections/{collection}/documents/search maps to lexical search.
  • /collections/{collection}/search maps to vector search.

Handler Ownership

AreaPrimary source fileRepresentative handlers
Health, metrics, links, runtimesrc/api/health.cppHandleHealth(), HandleReady(), HandleStats(), HandleMetrics(), HandleLinksList()
Collectionssrc/api/collections.cppHandleListCollections(), HandleCreateCollection(), HandleUpdateCollection()
Documentssrc/api/documents.cppHandleAddDocument(), HandleGetDocument(), HandleBulkImportDocuments()
Searchsrc/api/search.cppHandleSearch(), HandleGlobalSearch(), HandleMultiSearch()
Vector searchsrc/api/vector.cppHandleVectorSearch()
Maybe suggestionssrc/api/maybe.cppHandleMaybe()
Exportsrc/api/export.cppHandleExportDocuments()
Synonymssrc/api/synonyms.cppHandleListSynonyms(), HandleCreateOrUpdateSynonym()
Stopwordssrc/api/stopwords.cppHandleListStopwords(), HandleCreateStopword()
Overridessrc/api/overrides.cppHandleListOverrides(), HandleCreateOrUpdateOverride()
Aliasessrc/api/aliases.cppHandleListAliases(), HandleCreateOrUpdateAlias()
Userssrc/api/users.cppHandleListUsers(), HandleCreateUser()
Keyssrc/api/keys.cppHandleListKeys(), HandleCreateKey()
Modulessrc/api/modules.cppHandleListModules(), HandleModuleAPI(), HandleModuleSyntax()
Analyticssrc/api/analytics.cppHandleAnalyticsClick()
Storagesrc/api/storage.cppHandleStorageStatus()

Handler declarations live in include/api/searchapi.h.

Dispatch and Safety Gates

Before a handler runs, the HTTP layer may apply:

  • CORS preflight handling.
  • API key or bearer token authentication.
  • Admin-only checks for routes such as /keys, /users, /flush, and /admin/storage_status.
  • Metadata scan readiness checks for routes that need complete collection metadata.
  • Sync gating for write operations.
  • Module pre-check hooks for selected operations.

These gates are route-action based, so adding a new route normally requires updating both ResolveHttpRoute() and the action classification logic in src/api/httpserver.cpp.

Handler Categories

Health and Runtime

HandlerRoutesPurpose
HandleStatus()GET /, GET /status, GET /queryBasic server status.
HandleHealth()/healthHealth report suitable for probes. Clients should use GET.
HandleReady()GET /readyReadiness probe.
HandlePing()GET /pingMinimal ping response.
HandleStartup()GET /startup, GET /boot-statusStartup and boot report.
HandleStats()GET /statsRuntime and storage statistics.
HandleMetrics()GET /metrics, GET /metrics.jsonMetrics payload.
HandleMetricsHistory()GET /metrics/history, GET /metrics-historyHistorical metrics.
HandleEtc()GET /etcProtocol metadata used by clients.
HandleCache()GET /cacheCache statistics.
HandleSearchConfig()GET /search-configActive search configuration.
HandleConfigFiles()GET /config-filesActive configuration files and included files.

Collections and Documents

HandlerRoutesPurpose
HandleListCollections()GET /collectionsList collections.
HandleListCollectionsDistributed()GET /collections/distributedInclude linked nodes.
HandleCreateCollection()POST /collectionsCreate collection.
HandleGetCollection()GET /collections/{collection}Get collection metadata.
HandleGetCollectionLanguage()GET /collections/{collection}/langGet collection language.
HandleUpdateCollection()POST /collections/{collection}/updateUpdate schema.
HandleDeleteCollection()DELETE /collections/{collection}Delete collection.
HandleListDocuments()GET /collections/{collection}/documentsList documents.
HandleAddDocument()POST /collections/{collection}/documentsAdd document.
HandleBulkImportDocuments()POST /collections/{collection}/documents/importBulk import.
HandleGetDocument()GET /collections/{collection}/documents/{id}Get document.
HandleGetDocumentContext()GET /collections/{collection}/documents/{id}/contextGet document context.
HandleUpdateDocument()PUT /collections/{collection}/documents/{id}Update document.
HandleDeleteDocument()DELETE /collections/{collection}/documents/{id}Delete document.
HandleDeleteDocumentsByFilter()DELETE /collections/{collection}/documentsDelete by filter.
HandleUpdateByQuery()POST /collections/{collection}/documents/_update_by_queryUpdate by query.
HandleDeleteByQuery()POST /collections/{collection}/documents/_delete_by_queryDelete by query.
HandlerRoutesPurpose
HandleSearch()GET/POST /collections/{collection}/documents/search, GET/POST /sqlLexical, hybrid, and SQL-style search entry point.
HandleVectorSearch()GET/POST /collections/{collection}/vector_search, GET/POST /collections/{collection}/searchDedicated vector search.
HandleMultiSearch()GET/POST /multi_searchBatch search requests.
HandleGlobalSearch()GET/POST /searchGlobal search entry point.
HandleFacetCounts()GET/POST /collections/{collection}/documents/facet_countsFacet counts.
HandleExportDocuments()GET/POST /collections/{collection}/documents/exportExport matching documents.
HandleMaybe()GET/POST /collections/{collection}/documents/maybeQuery suggestions.

Dictionaries and Relevance Controls

HandlerRoutesPurpose
HandleListAllSynonyms()GET /synonymsList all synonym data.
HandleListGlobalSynonyms()GET /synonyms/globalList global synonyms.
HandleCreateOrUpdateGlobalSynonym()POST/PUT /synonyms/global/{id}Upsert global synonym.
HandleGetGlobalSynonym()GET /synonyms/global/{id}Get global synonym.
HandleDeleteGlobalSynonym()DELETE /synonyms/global/{id}Delete global synonym.
HandleListSynonyms()GET /collections/{collection}/synonymsList collection synonyms.
HandleCreateOrUpdateSynonym()POST/PUT /collections/{collection}/synonyms/{id}Upsert collection synonym.
HandleGetSynonym()GET /collections/{collection}/synonyms/{id}Get collection synonym.
HandleDeleteSynonym()DELETE /collections/{collection}/synonyms/{id}Delete collection synonym.
HandleListAllStopwords()GET /stopwordsList all stopwords.
HandleListGlobalStopwords()GET /stopwords/globalList global stopwords.
HandleCreateGlobalStopword()POST /stopwords/globalCreate global stopword.
HandleDeleteGlobalStopword()DELETE /stopwords/global/{word}Delete global stopword.
HandleListStopwords()GET /collections/{collection}/stopwordsList collection stopwords.
HandleCreateStopword()POST /collections/{collection}/stopwordsCreate collection stopword.
HandleDeleteStopword()DELETE /collections/{collection}/stopwords/{word}Delete collection stopword.
HandleListOverrides()GET /collections/{collection}/overridesList overrides.
HandleCreateOrUpdateOverride()POST/PUT /collections/{collection}/overrides/{id}Upsert override.
HandleGetOverride()GET /collections/{collection}/overrides/{id}Get override.
HandleDeleteOverride()DELETE /collections/{collection}/overrides/{id}Delete override.
HandleListPresets()GET /presetsList search presets.
HandleCreateOrUpdatePreset()POST/PUT /presets/{preset}Upsert search preset.
HandleGetPreset()GET /presets/{preset}Get search preset.
HandleDeletePreset()DELETE /presets/{preset}Delete search preset.
HandlerRoutesPurpose
HandleListAliases()GET /aliases, GET /collections/{collection}/aliasesList aliases.
HandleCreateOrUpdateAlias()POST/PUT /aliases/{alias}Upsert alias.
HandleGetAlias()GET /aliases/{alias}Get alias.
HandleDeleteAlias()DELETE /aliases/{alias}Delete alias.
HandleListKeys()GET /keysList API keys.
HandleCreateKey()POST /keysCreate API key.
HandleGetKey()GET /keys/{id}Get API key metadata.
HandleUpdateKey()PUT /keys/{id}Update API key.
HandleDeleteKey()DELETE /keys/{id}Delete API key.
HandleListUsers()GET /usersList users.
HandleCreateUser()POST /usersCreate user.
HandleGetUser()GET /users/{name}Get user.
HandleUpdateUser()PUT /users/{name}Update user.
HandleDeleteUser()DELETE /users/{name}Delete user.
HandleLinksList()GET /linksList cluster links.
HandleLinksPing()GET /links/pingPing links.
HandleLinksConnect()POST /links/connectAdd runtime link.
HandleLinksDisconnect()POST /links/disconnectRemove runtime link.
HandleListModules()GET /modulesList modules.
HandleModuleAPI()/loadmodule, /unloadmodule, /modules/{module}/...Module APIs.
HandleModuleSyntax()GET /modules/{module}/syntaxModule syntax.
HandleAnalyticsClick()POST /analytics/clickClick analytics.

Adding or Changing Routes

When adding a route, update these places together:

  1. Add route matching in src/api/httproutes.cpp.
  2. Add or reuse a RouteAction in include/api/httpserver.h.
  3. Dispatch the action in src/api/httpserver.cpp.
  4. Add the handler declaration in include/api/searchapi.h if needed.
  5. Implement the handler in the appropriate src/api/*.cpp file.
  6. Update Complete API Reference and endpoint-specific docs.

Common Error Responses

Handlers return JSON errors where possible:

{
"error": "Bad Request",
"message": "Invalid JSON body"
}

Status codes commonly used by handlers:

StatusMeaning
400Invalid request body, path, or query parameter.
401Authentication is required or invalid.
403Authenticated user or key lacks permission.
404Collection, document, or resource was not found.
405Method is not accepted by the matched handler.
409Resource conflict.
503Startup, metadata, or sync gate is temporarily blocking the route.
500Server-side failure.