Basker Docs

Search

Search the published content of a site with the FrontStage API, with filters, types, and pages of results

search queries the search index of the site. It uses the same terms, synonyms, boosts, and visibility rules as the search page of a site that Basker renders.

query Search($query: String!, $page: Int) {
  search(query: $query, page: $page, limit: 10) {
    totalDocs
    totalPages
    page
    hasNextPage
    docs {
      title
      excerpt
      collectionType
      image { url(transform: { width: 300, format: webp }) alt }
      node {
        __typename
        path
        ... on Event { startDate }
      }
    }
  }
}

With the variables {"query": "beethoven"}, the first result is:

{
  "title": "Beethoven Piano Concerto Cycle I",
  "excerpt": "Concertos 1 and 2 with our artist in residence.",
  "collectionType": "events",
  "image": null,
  "node": { "__typename": "Event", "path": "/events/beethoven-piano-concerto-cycle-i", "startDate": "2026-11-24T19:30:00.000Z" }
}

Arguments

ArgumentDescription
queryThe search text. Required. An empty query, or one longer than 256 characters, returns no results.
filterA SearchFilter value. Default ALL.
typesSearch only these types: pages, posts, events, people, or series.
page, limitPage number and page size. Default 10, maximum 50.
filterReturns
ALLEvery type.
EVENTSEvents that have not finished.
PAST_EVENTSEvents that have finished.
NEWSPosts.
PAGESPages.
PEOPLEPeople.
SERIESSeries.

Results

Each result has title, excerpt, collectionType, and image from the search index. node is the matching record, so you can select any of its fields. Results for records that are not published or not public do not appear.

Use node.path for the link.

Search as you type

Send a request when the visitor stops typing, not on every key press. Each distinct query is a separate URL, so short, common queries come from the edge cache.

let timer: ReturnType<typeof setTimeout> | undefined;

input.addEventListener("input", () => {
  clearTimeout(timer);
  timer = setTimeout(async () => {
    const { search } = await basker.query(SEARCH_QUERY, { query: input.value.trim(), page: 1 });
    renderResults(search.docs);
  }, 250);
});

On this page