The Simplest Way to Make Elasticsearch and Mercurial Work Like They Should
Teams use elasticsearch and mercurial together to search code history and commit logs fast. Mercurial stores your source code changes, while Elasticsearch indexes those records for quick queries. This setup helps developers find old commits, file changes, and bug fixes in seconds. Large repos grow slow when you search them with standard version control tools. Sending commit metadata to a search cluster fixes this speed problem for good. Your team can then run complex text queries across years o
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams use elasticsearch and mercurial together to search code history and commit logs fast. Mercurial stores your source code changes, while Elasticsearch indexes those records for quick queries.
This setup helps developers find old commits, file changes, and bug fixes in seconds. Large repos grow slow when you search them with standard version control tools. Sending commit metadata to a search cluster fixes this speed problem for good. Your team can then run complex text queries across years of project history.
How data and permissions flow in elasticsearch and mercurial
The workflow starts when a developer pushes new code to the central Mercurial server. A server hook or background worker picks up the new commit details right away. This worker formats the author name, timestamp, message, and file list into a document. Next, the worker sends that document over the network to the Elasticsearch cluster.
Both tools need clear login rules so only approved workers can move this data. The worker uses an API key or role account to write to the index. Developers then log in to their search app to read the indexed commit history. Their search role should only allow read queries on the specific project index.
Good permission design keeps write tasks separate from daily read tasks at all times. The ingestion script needs write rights, but human users only need read rights. This split prevents a user from changing or deleting search records by mistake.
Common failure modes and how to scope roles
Many teams fail by using one shared admin key for every script and user. If that key leaks in a repo, anyone can delete the entire search index. Another common mistake is leaving the search cluster open on a wide internal network. Unlogged queries also create risk because you cannot see who searched sensitive code.
You can fix these issues by setting strict role and network rules early. Give the Mercurial ingestion worker a role that only writes to one target index. Never give that worker permission to delete indices or change cluster settings. Put both servers on a private network segment with strict firewall rules between them.
Elasticsearch Security + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Commit messages and code diffs sometimes hold sensitive data by mistake. Developers might push test emails, phone numbers, card numbers, or national IDs in comments. When you use data masking, the system rewrites matched fields in results during queries. You should also log every search query and tie it to a single user.
Keeping your code search fast and safe
Syncing version control with a search engine takes constant care as teams grow. When new repos appear, you must create new roles and index rules for them. Manual key rotation across many repo hooks often leads to broken sync jobs.
Teams do best when they link search roles to their main identity provider. When an engineer leaves the team, removing their main account stops their search rights. You should also review index write logs each week to spot failed sync runs. Clear audit logs and tight roles keep both your code and search index safe.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Why index Mercurial commits in Elasticsearch instead of using native search?
Native Mercurial search scans commit history locally, which gets slow on big projects. Elasticsearch indexes the text ahead of time so queries across many repos finish fast.
What data should the sync worker send to the search index?
Send the commit hash, author, date, branch name, commit message, and changed file paths. Avoid indexing huge binary files so your search cluster stays fast and small.
How do we stop sensitive data in commits from showing in search results?
Clean the text before indexing or apply masking that rewrites matched fields in results. This step covers patterns like emails, phone numbers, and card numbers during read queries.
Related guides
In this post