Skip to content

Latest commit

 

History

History
113 lines (78 loc) · 28.6 KB

File metadata and controls

113 lines (78 loc) · 28.6 KB

Search

Overview

Available Operations

query

Search your organization's connected content and return ranked document results with cursor pagination. Use GET /api/search/filters to discover datasource identifiers and common filter fields. Built-in filter names are validated; other field names are accepted as custom filters and behavior depends on your Glean configuration and connected sources. Errors: HTTP 422 unprocessable_query returns no results or next_cursor. See warnings on the response for non-blocking issues such as partially available results. Not every query issue produces a warning or error.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.search.query(query="quarterly planning 2026", page_size=10, cursor="", datasources=[
        "confluence",
        "google_drive",
    ], filters=[
        {
            "field": "type",
            "values": [
                "spreadsheet",
                "presentation",
            ],
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
query str ✔️ The search query string. Supports inline operators such as from:jane type:document app:confluence. Inline operators are AND'd with structured filters.
page_size Optional[int] Number of results to return per page.
cursor OptionalNullable[str] Opaque pagination token from a previous response's next_cursor field. Omit on the first request.
datasources List[str] Restrict results to specific datasource identifiers returned by GET /api/search/filters. Scopes by datasource type and may include results from multiple instances of that type.
filters List[models.PlatformFilter] Structured filters applied to search results. Multiple values within a filter with EQUALS are OR'd; separate filters are AND'd. Conflicting constraints on the same field (for example, type:document in query and type:spreadsheet in a filter) return an empty result set. See Filter.field for built-in field names and operators. Other nonblank field names are accepted as custom filters without validation; behavior depends on your connected sources.
time_range Optional[models.PlatformTimeRange] Filter results to those last updated within this range.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformSearchResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 413, 422, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

list_filters

List datasources and common built-in filter fields visible to the authenticated user. This is a best-effort catalog, not an exhaustive list of every filter search accepts. Without query, returns field metadata only and does not run a search. With a nonblank query, provide exactly one datasources value to request suggested filter values for that query; no documents are returned and this endpoint does not include warning objects. See FilterFieldInfo.values for limitations on suggested values. Rate-limited requests return HTTP 429 with Retry-After; temporary backend unavailability returns HTTP 503.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.search.list_filters()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
datasources List[str] Restrict metadata to one or more datasource identifiers as returned by this endpoint (for example, jira). With a nonblank query, exactly one datasource is required. Unknown or inaccessible identifiers return invalid_datasource.
query Optional[str] Optional search query that requests suggested filter values for the selected datasource. Must be nonblank when present. Triggers a search for facet values only; does not return documents.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformSearchFiltersResponseResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*