Private/Get-GraphSynonymIndex.ps1

function Get-GraphSynonymIndex {
    <#
    .SYNOPSIS
        Loads and caches the shared free-text search synonym table.
    .DESCRIPTION
        Reads data/graph-search-synonyms.json, the same synonym table consumed by the
        GraphShell Explorer web app (index.html), so -Query recognizes concepts phrased with
        different vocabulary than the Microsoft Graph catalog itself (e.g. "secret" ->
        "password", "eligible" -> "eligibility"). There is a single synonym source of truth;
        this function only loads and caches it for the PowerShell module.
    #>

    [CmdletBinding()]
    [OutputType([pscustomobject])]
    param(
        [switch]$Force
    )

    if (-not $Force -and $script:GraphSynonymCache) {
        return $script:GraphSynonymCache
    }

    $paths = Get-GraphCatalogPath
    $byTerm = [System.Collections.Generic.Dictionary[string, string[]]]::new([System.StringComparer]::OrdinalIgnoreCase)

    if ($paths.SynonymsPath) {
        Write-Verbose "Loading GraphShell synonym index from $($paths.SynonymsPath)"
        $raw = Get-Content -LiteralPath $paths.SynonymsPath -Raw
        $parsed = $raw | ConvertFrom-Json
        foreach ($property in $parsed.synonyms.PSObject.Properties) {
            $byTerm[$property.Name] = [string[]]$property.Value
        }
    }
    else {
        Write-Verbose 'GraphShell synonym index (graph-search-synonyms.json) not found; -Query will run without synonym expansion.'
    }

    $script:GraphSynonymCache = [pscustomobject]@{ ByTerm = $byTerm }
    return $script:GraphSynonymCache
}