Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 16.9 KB

File metadata and controls

67 lines (48 loc) · 16.9 KB

Search

Overview

Available Operations

query

Execute a search query and retrieve ranked results. This is the data retrieval variant of the search API and returns only results and pagination state.

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, datasources=[
        "confluence",
        "google_drive",
    ], filters=[
        {
            "field": "type",
            "values": [
                "spreadsheet",
                "presentation",
            ],
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
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 datasources. Requests must not specify both datasources and datasource_instances.
datasource_instances List[str] Restrict results to specific datasource instances. Values are datasource instance identifiers returned by GET /api/search/filters. Requests must not specify both datasources and datasource_instances.
filters List[models.PlatformFilter] Structured filters applied to search results. Equality operators OR multiple values within a filter. Multiple filters are AND'd together, including range filters on the same field. Filters are AND'd with any inline operators in query. Note that conflicting constraints on the same field (e.g., type:document in the query and type: spreadsheet in a filter) produce an empty result set.
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, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*