The Simplest Way to Make Elasticsearch and Gerrit Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running elasticsearch and gerrit together gives engineering teams fast search across all code reviews. Gerrit manages git changes and approvals while Elasticsearch indexes change records, comments, and accounts. Small teams can use a basic built-in index for a single Gerrit server. Large teams with thousands of patches need an external search cluster to keep pages fast. This setup lets multiple Gerrit nodes share one search backend and stay in sync. How data and permissions flow between elast

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.

Running elasticsearch and gerrit together gives engineering teams fast search across all code reviews. Gerrit manages git changes and approvals while Elasticsearch indexes change records, comments, and accounts.

Small teams can use a basic built-in index for a single Gerrit server. Large teams with thousands of patches need an external search cluster to keep pages fast. This setup lets multiple Gerrit nodes share one search backend and stay in sync.

How data and permissions flow between elasticsearch and gerrit

Gerrit acts as the source of truth for code changes, review scores, and permissions. Whenever a developer pushes a patch or leaves a comment, Gerrit updates its database. Gerrit then sends a structured document to the search cluster over HTTP.

The search cluster stores separate indices for changes, accounts, groups, and projects. When a user searches the Gerrit web app, Gerrit queries the search cluster first. The search cluster returns matching document IDs, and Gerrit checks user read rules before showing results.

Because the search cluster holds sensitive review comments and emails, you must lock down log in rules. Gerrit needs a dedicated service identity with write rights on its own indices only. Developers and external apps should not query the search cluster directly without strict checks.

Common failure modes and how to scope roles and networks

Many teams connect these two tools using one shared admin key with full cluster rights. If that key leaks, an attacker can read private code descriptions or wipe indices. Broad keys also make it hard to tell which server or user ran a query.

Unlogged manual queries create another major blind spot during security audits. Engineers often log in to the search cluster to fix stuck review states or reindex changes. When everyone uses the same shared account, audit logs cannot tie actions to a real person.

Elasticsearch Security + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, place both tools inside a private network segment with strict firewall rules. Only Gerrit servers and approved admin hosts should reach the search cluster port. Create a scoped role for Gerrit that only allows index updates and searches on Gerrit data.

Next, separate machine traffic from human maintenance work. Give each Gerrit node its own credential and rotate those keys on a regular schedule. Require individual identity checks whenever an engineer runs manual queries or index fixes against the cluster.

Keeping search indices in sync during upgrades

Schema updates during a Gerrit upgrade can break search if you do not plan ahead. New Gerrit versions often change how review fields map inside the search index. When that happens, you must run a full reindex job to build the new index version.

During an online reindex, Gerrit writes to both the old and new indices at once. Keep an eye on disk space and memory use on the search nodes during this job. Once the new index finishes building, Gerrit switches read traffic over and drops the old index.

You should also test search queries in a staging setup before touching production. Check that custom search filters and automated build bots still return the right patches. Clean role design and good logs make these upgrades safe and predictable for your team.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why use an external search cluster with Gerrit?

An external search cluster handles large patch volumes and lets multiple Gerrit servers share one search index. This setup improves search speed and supports high availability across nodes.

What data does Gerrit send to the search index?

Gerrit sends change metadata, commit messages, review comments, approval scores, project names, and user account details. It does not need to store full source code blobs if you disable file content indexing.

How do you secure traffic between the two systems?

Use TLS encryption for all HTTP traffic between Gerrit and the search nodes. Restrict the Gerrit service account to the exact indices it needs and block public network routes.

The query runs. The emails stay hidden.