Skip to main content
InterviewHubPRO
Section Overview
Q38

Question 38 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

76%
Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Reindexing Patterns and Zero-Downtime Index Migrations: Index Aliases and the `_reindex` API.

senior LevelMost AskedCode ExampleDatabases & SQLHTTP & REST APIs

In Simple Words: Because Lucene inverted indexes are immutable, changing field data types or analyzers requires creating a new index and reindexing documents:

  • Index Aliases: Never point applications directly to a raw index name (orders_v1). Always query through a logical alias (orders).
  • Zero-Downtime Reindex Workflow:
    1. Create new index orders_v2 with updated mapping.
    2. Run asynchronous reindexing: POST _reindex?wait_for_completion=false.
    3. Atomically swap alias from v1 to v2:
      json
      POST /_aliases
      {
        "actions": [
          { "remove": { "index": "orders_v1", "alias": "orders" } },
          { "add":    { "index": "orders_v2", "alias": "orders" } }
        ]
      }
      
    4. Delete legacy index orders_v1 once validated.