# Google Vault query builder and export scoping workbench

> Build a Vault search, preview how much data it would actually pull, tighten it until the scope is defensible, and only then run the export.

- Workflow type: app
- Services: Google Vault, Google Docs
- Categories: Operations
- Published: 2026-08-24

## What it does

- Build a Vault search in one place: pick the data source (Mail, Drive, Groups, Chat, Voice, Calendar, or Gemini), who or where to search, a date range with time zone, and your search terms.
- Preview the volume before you commit. One click counts what the search would actually return and shows the per account and per data source numbers in a comparison table, so you can tighten terms and dates and re-count until the scope holds up.
- Save the searches that work to a matter and reuse them later, and run every export from the same screen with live status, size, and item counts.
- Paste a plain English discovery or privacy request and a background agent drafts candidate searches, compares their volumes, saves the tightest one, and writes a scoping memo into Google Docs.

## What you'll need

- A Google Workspace account with Google Vault access, and permission to run searches and exports
- At least one matter already set up in Vault to work inside
- A Google account that can create Google Docs, so the agent can write its scoping memo

## Prompt

Build me a search and export scoping workbench for Google Vault. Today my team guesses at scope, fires an export, and discovers hours later that it was far too broad, which costs real money once the data hits processing and hosting. I want one screen where I build a query, preview how much it would actually return, tighten it, and only then export. Load the matters I have access to with List Matters and let me pick which matter I am working in from a selector at the top of the app. Everything else in the app is scoped to the selected matter.

The main surface is a query builder. Let me pick the data source (corpus): Mail, Drive, Groups, Chat, Voice, Calendar, or Gemini. Let me pick the search method: specific accounts as a list of email addresses, an org unit, a shared drive, a Chat room, or entire org for Gmail only. Let me set a start time, an end time, an IANA time zone such as America/New_York, and free text search terms using the service specific operators. Surface the per source options that actually change results: exclude drafts for Mail, include shared drives for Drive, include rooms for Chat, and a data scope selector for all data, held data, or unprocessed data. Hold the builder state as a single Query object and reuse it verbatim for counts, saved queries, and exports so what I previewed is exactly what I save and export.

A Preview volume button runs Count Accounts with the current query, then polls Get Operation on the returned operation name until it reports done, showing a live counting state while it waits. When it finishes, render the result counts in a comparison table broken out per account and per data source. Keep the last several previews as rows in that table so I can see how a change to terms or dates moved the volume, and let me re run a count after editing without losing the earlier rows. That side by side comparison is the point of the app: I tighten and re count until the scope is defensible and affordable.

A sidebar lists my reusable saved queries for the selected matter with List Saved Queries. Clicking one loads it back into the builder with Get Saved Query, and each row has a delete action using Delete Saved Query behind a confirm. When a query looks right, a Save to matter button persists it with Create Saved Query under a name I type, so the next request starts from a known good scope instead of a blank page.

A separate Exports tab lists everything in flight and finished for the matter with List Exports, and refreshes individual rows with Get Export. Show status, export size, and item counts on every row. Give me a button to launch a new export from a saved query with Create Export, and a button to clean up old exports with Delete Export behind a confirm.

Add a Scope this request button that kicks off a background agent. I paste a plain English discovery or privacy request, for example everything Dana sent or received about the Northwind contract between March and June. The agent drafts candidate queries for each relevant data source, runs Count Accounts on each candidate and polls Get Operation until done, compares the volumes across candidates, and saves the best scoped query to the matter with Create Saved Query. It then writes a scoping memo into Google Docs: Create Document for a titled memo, then Batch Update Document to fill in what it searched, the volumes it found for each candidate, which query it recommends, and what it recommends exporting and why. Show the agent progress in the app, and when it lands, link the finished memo and the new saved query from the workbench.

Bake in the real constraints. Counts and exports are long running operations, so never read a result directly: always poll Get Operation until it reports done, with a visible waiting state and a sensible timeout rather than an indefinite spinner. Vault allows roughly 60 queries per 100 seconds, so stagger repeated counts instead of fanning out hard, especially while the agent is counting several candidates at once. An export running past 24 hours can come back partial and need a re run, so warn about that on the exports tab and flag any export that has been running a long time. Gemini supports search and export only, not holds, and Gemini exports are XML output, so note that in the builder whenever Gemini is the selected data source.

## How to customize

- Default the date range, time zone, and data sources to whatever your legal team uses most, so a new search starts closer to the right shape
- Set your own volume thresholds so the workbench flags a search as too broad before anyone runs an export
- Adjust what the scoping memo covers, including how the agent justifies its recommendation and what it tells reviewers to export

## FAQ

### Why does the volume preview take a moment to come back?

Vault runs counts as background jobs rather than returning a number instantly. The app starts the count, waits for it to finish, and shows a counting state until the result is ready. Big searches across many accounts take longer than narrow ones.

### Will this stop me from running an export that is too big?

It does not block you, but it makes the size visible before you commit. You see the account and item counts first, and can keep tightening terms and dates and re-counting until the numbers look reasonable. That is the whole point of previewing rather than guessing.

### What happens if an export runs for more than 24 hours?

Vault can return a partial export when a job runs past 24 hours, which means starting another one. The exports tab shows how long each export has been running and flags the long ones so you catch it rather than finding out when you open the files.

### Does this work with Gemini data?

Yes, for search and export. Gemini exports come back in XML format only, and the builder notes that when Gemini is the selected data source so nobody is surprised by the file format later.

### Do I need to create matters inside this app?

No. The app lists the matters you already have access to and lets you pick which one you are working in. Saved queries and exports are then scoped to that matter.

Use this prompt in General Input: https://www.generalinput.com/prompts/google-vault-query-builder-and-export-scoping-workbench