Saved Elasticsearch queries anyone on your team can run
Turn the five queries your engineers keep rewriting into a library of simple forms, so anyone can pull the data themselves.
Build me a saved query library that turns our Elasticsearch cluster into something the whole company can self-serve from. Right now our engineers rewrite the same five queries every week, and everyone else files a "can you pull this for me" request. This app is the surface that replaces both.
The main view is the library itself: every saved query rendered as a card showing a plain-English name, a one-line description of what question it answers, who owns it, which data it reads, and the parameters it takes. Cards are searchable and filterable by owner and by data source. This is the page people land on, so it has to be scannable by someone who has never written a query in their life.
Opening a card shows a simple form, never query syntax. The standard fields are a date range picker, a service dropdown, a customer ID box, and a status dropdown, but each saved query declares which parameters it actually takes and the form renders only those. Pressing Run executes the Elasticsearch Search Documents (Query Index) operation against that query's target index with the parameter values filled in, and renders the matching rows as a sortable table whose columns come from the fields the query returns. Above the table, show the total using the Count Documents operation run with the same filters, so people see something like "showing 50 of 3,412" rather than an unqualified page of rows.
Put the generated query behind an Advanced toggle, collapsed by default. Engineers need to audit exactly what runs before they will trust the library, but nobody else should ever see it. Do the same with failures: if a run breaks, say so in plain language on the surface and keep the raw error inside Advanced.
Every result view has a Share results button that posts a summary to a Slack channel using the Slack Bot Send a Message operation: the query name, the parameter values that were used, the total count, and the first handful of rows formatted readably. Let the person pick the channel.
The saved queries themselves live in their own Elasticsearch index inside the same cluster. Create it once on first run with the Create Index operation, with an explicit mapping. Each saved query document holds a name, a description, an owner, the target index, the query body with placeholders for its parameters, the parameter definitions (name, label, type, default value, whether it is required), a created date, a run count, a last-run timestamp, and an active or retired status. New entries are written with the Index (Create or Replace) Document operation, and edits use Update Document.
When someone defines a query by hand, an index picker built from the List Indices operation shows the data sources available along with doc count and size, so they can tell a live source from a leftover. Choosing one calls the Get Index Schema (Mapping and Settings) operation and lists the fields that actually exist with their types, so nobody has to guess at a field name. Let an admin restrict which indices appear in that picker.
The headline feature is a "Describe what you need" button that starts a background agent, and it deserves the most attention in the build. The person picks a data source and types what they want in plain English, something like "failed checkout attempts by payment provider last week". The agent then does the work an engineer would do. It reads the target index mapping with Get Index Schema to learn the real field names and types. It samples real documents with Search Documents to learn what the values actually look like, because a mapping tells it there is a status field but only real rows tell it whether a failure is recorded as "failed", "declined", or a numeric code. It drafts a query, test-runs it with Search Documents, and inspects what came back: zero rows or obviously wrong rows means the guess was wrong, so it adjusts the field names, the value matching, or the time field and tries again. It keeps that draft-and-test loop running until the query returns sensible rows.
When it has something that works, the agent decides which parts of the request should become parameters rather than hard-coded values. "Last week" becomes a date range parameter, "by payment provider" becomes a provider dropdown, and so on, so the saved entry is reusable instead of a one-off. It then writes the entry into the library index with Index (Create or Replace) Document, giving it a plain-English name and a description of the question it answers. Show the agent's progress in the app while it runs, in plain language, so the person can watch it reading the structure, sampling records, and testing. The finished entry lands in the library marked as needing review, with its test rows shown, so the person who asked can rename it, correct the description, and confirm before it goes live for everyone. The agent must only ever write to the saved query library index, never to any other index in the cluster.
This agent is the reason the library grows. Every time somebody asks a question that is not already in the library, the answer becomes a permanent, named, parameterized entry the next person can simply run, without an engineer ever writing a query.
Track a run count and a last-run timestamp on every saved query, incremented with the Update Document operation each time someone runs it. Surface both on the card, and add a view sorted by least recently used so dead queries can be spotted and retired. Retiring hides an entry from the main library without deleting it.
Throughout the interface, use ordinary words rather than Elasticsearch vocabulary. Say "data source" or "table" rather than "index", "record" or "row" rather than "document", and "date range" rather than anything about ranges or filters. The phrases "Query DSL", "bool filter", and "aggregation" should never appear anywhere a non-engineer can see them. The entire point is that someone in finance or support can pull their own numbers without learning what an index is.
Two technical notes for the build. Page results with search_after and a stable sort that includes a tiebreaker field, not deep from and size paging, because standard pagination caps at 10,000 by default and this library will hit that on log-shaped indices. And pass track_total_hits when the total needs to be exact, otherwise hits.total silently flattens at 10,000 and the count above the table will be wrong. Elasticsearch is authenticated per cluster with a user-supplied base URL and key, so never hard-code a host anywhere in the app.
What does this prompt do?
- Lists every saved query as a card with a plain-English name, a description of what it answers, its owner, and the data it reads, so people find what they need without asking anyone
- Opens each one as a simple form (date range, service, customer ID, status) and shows the results as a sortable table with a total count, with no query syntax anywhere on the screen
- Adds a Describe what you need button: type a request in plain English like 'failed checkout attempts by payment provider last week' and a background assistant figures out the query, tests it against your real data, and saves it to the library as a reusable entry
- Shares any set of results to a Slack channel in one click, so the answer lands where the team is already talking
- Counts how often each saved query gets run and when it was last used, so dead ones can be retired, and keeps an Advanced view where an engineer can audit exactly what runs
What do I need to use this?
- An Elasticsearch cluster holding the data your team keeps asking about, plus a key the app can connect with
- Permission for the app to create one new index to store the saved queries themselves. It sets this up on first run
- A Slack workspace and the channel where results should be shared
- A rough idea of which data your team should be allowed to query, so the picker can be limited to those sources
How can I customize it?
- Choose which data sources appear in the picker, so people only see the ones they are allowed to query
- Change the standard form fields (date range, service, customer ID, status) to whatever your team actually filters on
- Decide who can create and edit saved queries versus who can only run them, and set the default channel for sharing results
FAQs
Do people need to know how to write Elasticsearch queries?
How does the Describe what you need button actually work?
Can engineers still check exactly what runs?
Where do the saved queries live?
How do we stop the library filling up with junk nobody uses?
Related templates
Stage a batch of filings overnight, then approve each completed form from a screenshot before anything is ever submitted.
Pick a client and a date range to see sent, replies, meetings booked and the real deal value your cold email produced, campaign by campaign.
Review every conversation Fin closed as resolved, judge which ones actually stuck, and see what the gap is worth against your bill.
Merge your IT, HR and Facilities queues into one list ranked by SLA time left, then reply, change status and escalate without ever opening Jira.
See every page's translation status at a glance, edit translations side by side with the English, and publish only what your team has actually approved.
One place for sales and ops to request an NDA or vendor agreement, watch its status, and let legal launch the contract in a single click.
Stop being the person who runs everyone else's queries.
Turn the same five queries your engineers rewrite every week into a library the whole company can serve itself from.