Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juescoryisus/QualityDocD/llms.txt

Use this file to discover all available pages before exploring further.

QualityDocD provides two search interfaces backed by two search engines. The .NET application’s Reports/Search page and the PHP portal’s Documents page both query the Search Service first, falling back to SQL Server (or PostgreSQL token index) when the service is unavailable. The Node.js API exposes a lower-level search endpoint with granular control over search mode and field targeting. This guide explains how each interface works and when to use each one.
For the fastest search response, use mode=metadata in the Node.js API. This queries the MongoDB $text index, which is optimized with per-field weights (title: 10, tags: 5, standard: 3, description: 1). Use mode=all when you need the most complete results, combining metadata and full-text content matching.

Search interfaces

The .NET application exposes a search report at GET /Reports/Search. This interface accepts the parameters q, category, and status, and internally calls the Search Service. If the Search Service is unavailable, it falls back to a SQL Server query against titles, descriptions, codes, and tags.Endpoint:
GET /Reports/Search?q={query}&category={category}&status={status}
ParameterDescription
qFree-text search term matched against title, description, code, and tags.
categoryFilter by document category (e.g., Manual, Procedure, Record, Audit).
statusFilter by document status (e.g., Approved, Draft).
Results are returned as cards showing the document code, status badge, title, category, standard, and up to five tags. Each card links to the document detail page in the .NET app.
Access to /Reports/Search requires the Admin, Manager, or Reviewer role. Unauthenticated or Viewer-only users are redirected to login.
Fallback behavior: When the Search Service HTTP call fails or returns a non-success status code, the .NET app automatically falls back to a SQL Server query. The fallback returns up to 50 results ordered by creation date descending.Example curl:
curl "https://your-app/Reports/Search?q=quality+manual&category=Manual&status=Approved"

Search modes

The Node.js API GET /search supports three modes that control which engines are queried:
ModePrimary engineFallbackmatchedIn value
metadataMongoDB $text index on title, description, tags, standardPostgreSQL token indexmetadata or title/body/both
contentMongoDB regex search on contentTextNonecontent
allBoth metadata and contentPostgreSQL token index for metadata halfmetadata, content, or metadata+content
When mode=metadata (or mode=all) and a non-empty q is provided, the search queries the MongoDB document_metadata collection using a $text index with the following field weights:
FieldWeight
title10
tags5
standard3
description1
Results are sorted by text score (highest relevance first), limited to 30 documents per query.

PostgreSQL token fallback

If the MongoDB query fails (e.g., MongoDB is offline), the metadata search falls back to the PostgreSQL search_index table. The fallback tokenizes the query and matches against pre-built titleTokens and bodyTokens arrays stored per document version. The field parameter controls whether only title tokens, only body tokens, or both are checked. When mode=content (or mode=all) and q is non-empty, a MongoDB regex search ($regex, case-insensitive) is performed against the contentText field. If a document was already found in the metadata pass, its matchedIn field is updated to metadata+content rather than adding a duplicate result.

Autocomplete suggestions

GET /search/suggest?q={prefix}
Returns up to 10 autocomplete suggestions based on a prefix match against document titles in MongoDB. Requires at least 2 characters in q. Access requirement: MODULE_3 (OPERATOR role or higher). Response:
{
  "suggestions": [
    { "id": 42, "title": "Quality Manual ISO 9001" },
    { "id": 57, "title": "Quality Procedure QP-001" }
  ]
}

Manually re-indexing a document version

POST /search/index
Body: { "versionId": 17 }
Forces a specific document version to be re-indexed in the PostgreSQL token index. This is useful if a document’s content was updated outside the normal approval flow or if the index entry became stale.
Manual re-indexing via POST /search/index requires MODULE_1 access (OPERATOR role or higher). Documents are automatically indexed when a version is approved via POST /documents/:id/versions/:versionId/approve — manual re-indexing is only needed for exceptional cases.

Automatic indexing

Documents are automatically synced to the Search Service whenever they are created, updated, submitted for review, approved, rejected, or marked obsolete in the .NET application. The sync call posts document metadata (id, code, title, description, category, standard, tags, fileExtension, status, isPublic) to POST /api/documents on the Search Service, which upserts the record in the MongoDB document_metadata collection. If the Search Service is unavailable during a sync, the error is logged as a warning and the primary operation (create/update/approve) continues without being blocked.

Build docs developers (and LLMs) love