Indexing API Cmdlets
The Indexing API cmdlets in glean-powershell provide a PowerShell interface for managing Glean data sources, documents, users, groups, and permissions via the Indexing API. These cmdlets are generated wrappers that map PowerShell parameters to the JSON request bodies required by the Glean REST API, handling serialization, HTTP invocation, and response parsing.
Datasource Management
Section titled “Datasource Management”The Add-GleanDatasource cmdlet allows users to add or update a custom datasource and its schema 1. It accepts a wide range of parameters that map directly to the request body fields, such as Name (the unique identifier), DisplayName, DatasourceCategory, and UrlRegex. Configuration options include IconUrl, IconDarkUrl, HomeUrl, and CrawlerSeedUrls for web crawling datasources. Advanced settings allow for URL and title canonicalization via CanonicalizingURLRegex and CanonicalizingTitleRegex, as well as redlisting titles with RedlistTitleRegex. The cmdlet also supports configuring Quicklinks, RenderConfigPreset, Aliases, and identity-related settings like IdentityDatasourceName and ProductAccessGroup. For non-idempotent operations, the RetryUnsafe switch permits retries on HTTP 429/503 errors.
Document Indexing
Section titled “Document Indexing”Single document indexing is handled by Add-GleanDocument, which adds a document to the index or updates an existing one 2. This cmdlet requires a Document hashtable and optionally accepts a Version for optimistic concurrency control. For bulk operations, Add-GleanDocumentIndex adds or updates multiple documents in the index 3. It requires a Datasource name and a Documents array, and optionally accepts an UploadId to track the batch. Both document indexing cmdlets support a Body parameter for passing the full request body verbatim, which is useful for complex nested structures 2 3.
Common Invocation Pattern
Section titled “Common Invocation Pattern”All indexing cmdlets follow a consistent internal structure. They define parameters in a Fields parameter set and a Body parameter set 1 2 3. In the process block, they construct a hashtable $__invoke containing the API name (indexing), HTTP method (POST), and specific path (e.g., /adddatasource, /indexdocument, /indexdocuments) 4 2 3. The cmdlet then calls Invoke-GleanRequest with this hashtable, passing the constructed body and any specified switches like RetryUnsafe or Raw 4 2 3.
<#
.SYNOPSIS
Add or update datasource
.DESCRIPTION
Add or update a custom datasource and its schema.
.PARAMETER Name
Unique identifier of datasource instance to which this config applies. (maps to body 'name') Required.
.PARAMETER DisplayName
The user-friendly instance label to display. If omitted, falls back to the title-cased `name`. (maps to body 'displayName')
.PARAMETER DatasourceCategory
The type of this datasource. It is an important signal for relevance and must be specified and cannot be UNCATEGORIZED. Please refer to [this](https://developer (maps to body 'datasourceCategory')
.PARAMETER UrlRegex
Regular expression that matches URLs of documents of the datasource instance. The behavior for multiple matches is non-deterministic. **Note: `urlRegex` is a re (maps to body 'urlRegex')
.PARAMETER IconUrl
The URL to an image to be displayed as an icon for this datasource instance. Must have a transparency mask. SVG are recommended over PNG. Public, scio-authentic (maps to body 'iconUrl')
.PARAMETER ObjectDefinitions
The list of top-level `objectType`s for the datasource. (maps to body 'objectDefinitions')
.PARAMETER SuggestionText
Example text for what to search for in this datasource (maps to body 'suggestionText')
.PARAMETER HomeUrl
The URL of the landing page for this datasource instance. Should point to the most useful page for users, not the company marketing page. (maps to body 'homeUrl')
.PARAMETER CrawlerSeedUrls
This only applies to WEB_CRAWL and BROWSER_CRAWL datasources. Defines the seed URLs for crawling. (maps to body 'crawlerSeedUrls')
.PARAMETER IconDarkUrl
The URL to an image to be displayed as an icon for this datasource instance in dark mode. Must have a transparency mask. SVG are recommended over PNG. Public, s (maps to body 'iconDarkUrl')
.PARAMETER HideBuiltInFacets
List of built-in facet types that should be hidden for the datasource. (maps to body 'hideBuiltInFacets')
.PARAMETER CanonicalizingURLRegex
A list of regular expressions to apply to an arbitrary URL to transform it into a canonical URL for this datasource instance. Regexes are to be applied in the o (maps to body 'canonicalizingURLRegex')
.PARAMETER CanonicalizingTitleRegex
A list of regular expressions to apply to an arbitrary title to transform it into a title that will be displayed in the search results (maps to body 'canonicalizingTitleRegex')
.PARAMETER RedlistTitleRegex
A regex that identifies titles that should not be indexed (maps to body 'redlistTitleRegex')
.PARAMETER ConnectorType
connectorType (maps to body 'connectorType')
.PARAMETER Quicklinks
List of actions for this datasource instance that will show up in autocomplete and app card, e.g. "Create new issue" for jira (maps to body 'quicklinks')
.PARAMETER RenderConfigPreset
The name of a render config to use for displaying results from this datasource. Any well known datasource name may be used to render the same as that source, e. (maps to body 'renderConfigPreset')
.PARAMETER Aliases
<#
.SYNOPSIS
Index document
.DESCRIPTION
Adds a document to the index or updates an existing document.
.PARAMETER Version
Version number for document for optimistic concurrency control. If absent or 0 then no version checks are done. (maps to body 'version')
.PARAMETER Document
Indexable document structure (maps to body 'document') Required.
.PARAMETER Body
The full request body as a hashtable, sent verbatim. Use this instead of the individual
field parameters when the body uses oneOf/anyOf shapes or deeply nested objects.
.PARAMETER Raw
Return the raw, undeserialized HTTP response instead of the parsed object.
.PARAMETER RetryUnsafe
Allow this non-idempotent operation to be retried on HTTP 429/503. Off by default to avoid
duplicating side effects.
.LINK
https://developers.glean.com/api/indexing-api/addOrUpdate
.EXAMPLE
Add-GleanDocument -Document <Document>
#>
function Add-GleanDocument {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'Fields')]
[OutputType([object])]
param(
[Parameter(ParameterSetName = 'Fields', HelpMessage = 'Version number for document for optimistic concurrency control. If absent or 0 then no version checks are done.')]
[long]
${Version},
[Parameter(Mandatory = $true, ParameterSetName = 'Fields', HelpMessage = 'Indexable document structure')]
[hashtable]
${Document},
[Parameter(ParameterSetName = 'Body', HelpMessage = 'The full request body, sent verbatim.')]
[hashtable]
${Body},
[Parameter(HelpMessage = 'Permit retry of this non-idempotent call on 429/503.')]
[switch]
<#
.SYNOPSIS
Index documents
.DESCRIPTION
Adds or updates multiple documents in the index. Please refer to the [bulk indexing](https://developers.glean.com/indexing/documents/bulk-indexing/choosing-indexdocuments-vs-bulkindexdocuments) documentation for an explanation of when to use this endpoint.
.PARAMETER UploadId
Optional id parameter to identify and track a batch of documents. (maps to body 'uploadId')
.PARAMETER Datasource
Datasource of the documents (maps to body 'datasource') Required.
.PARAMETER Documents
Batch of documents being added/updated (maps to body 'documents') Required.
.PARAMETER Body
The full request body as a hashtable, sent verbatim. Use this instead of the individual
field parameters when the body uses oneOf/anyOf shapes or deeply nested objects.
.PARAMETER Raw
Return the raw, undeserialized HTTP response instead of the parsed object.
.PARAMETER RetryUnsafe
Allow this non-idempotent operation to be retried on HTTP 429/503. Off by default to avoid
duplicating side effects.
.LINK
https://developers.glean.com/api/indexing-api/index
.EXAMPLE
Add-GleanDocumentIndex -Datasource <Datasource> -Documents <Documents>
#>
function Add-GleanDocumentIndex {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'Fields')]
[OutputType([object])]
param(
[Parameter(ParameterSetName = 'Fields', HelpMessage = 'Optional id parameter to identify and track a batch of documents.')]
[string]
${UploadId},
[Parameter(Mandatory = $true, ParameterSetName = 'Fields', HelpMessage = 'Datasource of the documents')]
[string]
${Datasource},
[Parameter(Mandatory = $true, ParameterSetName = 'Fields', HelpMessage = 'Batch of documents being added/updated')]
[hashtable[]]
${Documents},
Method = 'POST'
Path = '/adddatasource'
PathParam = $__pathParams
Query = $__query
QueryMeta = $__queryMeta
Header = $__headers
}
if ($null -ne $__body) { $__invoke['Body'] = $__body }
if ($RetryUnsafe) { $__invoke['Idempotent'] = $true }
if ($Raw) { $__invoke['Raw'] = $true }
$__caller = 'Invoke-GleanRequest'
if ($PSCmdlet.ShouldProcess('/adddatasource', 'Add-GleanDatasource')) {
& $__caller @__invoke
}
}
}