Seamless Deployments with Elasticsearch and Hibernate Search: Rolling Strategy

Update Elasticsearch mappings in rolling deployments on Kubernetes with zero downtime, using index versioning, atomic aliases, and reindexing with Hibernate Search.

lunes, 18 de agosto de 2025 • 3 min read • Q2BSTUDIO Team

Artificial-Intelligence-

In this article, we explain how to update Elasticsearch mappings during rolling deployments in Kubernetes without interrupting search, applying a proven strategy with Hibernate Search that guarantees zero downtime and high availability.

Why mappings and deployments are delicate Mappings define the structure of the index, and some changes are hot-compatible, such as adding fields, while others are incompatible and require creating a new index. A traditional deployment that changes mappings can cause query errors or interruptions if the application and the index are not aligned.

General strategy The strategy we recommend combines index versioning, atomic Elasticsearch aliases, and controlled reindexing with Hibernate Search. The key idea is to keep the old index in production until the new index with the updated mapping is fully reindexed and tested, and then perform an alias switch without losing queries.

Step 1 Prepare a new versioned index Create a new index with a name that includes a version, for example indexname_v2, and apply the definitive mapping. If the change is compatible, the mapping can be updated hot, but for incompatible changes, always create a new index.

Step 2 Safe reindexing with Hibernate Search Use Hibernate Search MassIndexer or a controlled reindexing task to populate the new index. Run the reindexing from pods that are not rolled out until completion, or from a dedicated Kubernetes job. During this process, keep the read alias pointing to the old index to ensure searches continue to work.

Step 3 Dual-write or event queues To avoid data loss between the start of reindexing and the final cutover, apply dual-write temporarily. Configure the application to send writes to both the old and new index via a write alias pointing to both indexes, or use an event layer that replays modifications to the new index until the switch is performed.

Step 4 Atomic alias switch Once reindexing completes and search results and performance are validated, use the Elasticsearch aliases API to move the read and write aliases to the new index in an atomic operation. This ensures there is no window in which searches cannot find documents.

Step 5 Retire the old index After the change and an observation period, delete the old index to free up space. Keep monitoring and alerts that verify latencies and errors after the switch. If something fails, versioning allows quickly reverting to the previous index.

Best practices with Kubernetes Integrate these steps into your CI/CD pipeline and use readiness and liveness probes so Kubernetes does not send traffic to pods that are exclusively reindexing. Run reindexing from Kubernetes jobs or maintenance pods to avoid harming the service capacity of pods that handle production queries.

Hibernate Search configuration In production environments, we recommend disabling Hibernate Search automatic schema management and managing mappings and indexes manually or with controlled scripts. Hibernate Search facilitates reindexing and JPA integration, and its MassIndexer is useful for massive reindexing without blocking the application.

Use case and advantages With this strategy, zero downtime in searches is achieved, full control over mapping changes, and the ability to quickly revert. It is especially useful for applications with critical real-time search requirements, microservices deployed on Kubernetes, and workloads that cannot tolerate interruptions.

Q2BSTUDIO and how we can help At Q2BSTUDIO, we are a software development company specialized in custom applications and custom software. We offer complete services in artificial intelligence, AI for businesses, AI agents, and Power BI solutions, as well as cybersecurity, AWS and Azure cloud services, and business intelligence services. We can design and implement the indexing, reindexing, and rolling deployment strategy on Kubernetes, integrating Hibernate Search with Elasticsearch and ensuring zero downtime in searches for your custom applications.

Contact and next steps If you need support to implement zero-downtime deployments, mapping migrations, or advanced search solutions, at Q2BSTUDIO we have specialists in artificial intelligence, cybersecurity, and cloud architecture who can advise you at every stage. Our experience in custom software and AWS and Azure cloud services guarantees a secure and efficient execution for projects of any scale.

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.