CROP
ProjectsParts Services

Dual-Index Architecture Fix Plan

Current Status - Parts Index: ✅ Working ( alias → ) - Tires Index: ❌ Broken (no alias, raw index created by sync)

Dual-Index Architecture Fix Plan

Current Status

  • Parts Index: ✅ Working (parts_current alias → parts_v2026_01_20)
  • Tires Index: ❌ Broken (no alias, raw index created by sync)

Root Cause Analysis

Problem 1: Missing Tires Index Setup

The sync workflow writes directly to tires_current without first creating:

  1. A versioned index (tires_v{timestamp})
  2. Proper aliases (tires_current_read, tires_current_write)

Problem 2: Missing Environment Variable

Cloud Run deployment doesn't set TIRES_INDEX_NAME environment variable.

Problem 3: Incomplete Health Check

Health endpoint only monitors parts_current, not tires_current.

Fix Implementation

Step 1: Create Tires Index Setup Script

Create services/search/scripts/setup-tires-index.ts:

  • Create tires_v{timestamp} index with same mapping as parts
  • Create aliases: tires_current_read, tires_current_write

Step 2: Update Workflow

Add step before tires sync:

- name: Create Tires index if needed
  run: |
    export SERVICE_IMAGE="${REGISTRY}/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA}"
    bash services/search/scripts/gcp-create-tires-index.sh

Step 3: Add Environment Variable

Update Cloud Run deploy step:

--set-env-vars="...@TIRES_INDEX_NAME=tires_current@..."

Step 4: Update Health Endpoint

Modify /health to check both indices:

{
  parts: { alias: "parts_current", target: "...", docs: N },
  tires: { alias: "tires_current", target: "...", docs: N }
}

Immediate Workaround

Run manually on ES cluster:

# 1. Create versioned index with mapping
PUT /tires_v2026_01_21
{
  "settings": { ... },
  "mappings": { ... }
}

# 2. Create aliases
POST /_aliases
{
  "actions": [
    { "add": { "index": "tires_v2026_01_21", "alias": "tires_current_read" }},
    { "add": { "index": "tires_v2026_01_21", "alias": "tires_current_write" }},
    { "add": { "index": "tires_v2026_01_21", "alias": "tires_current" }}
  ]
}

# 3. Re-run tires sync

Files to Modify

  1. services/search/scripts/setup-tires-index.ts - NEW
  2. services/search/scripts/gcp-create-tires-index.sh - NEW
  3. .github/workflows/search-deploy.yml - Add tires index creation step
  4. .github/workflows/search-deploy.yml - Add TIRES_INDEX_NAME env var
  5. services/search/src/routes/health.ts - Check both indices
  6. services/search/scripts/switch-alias-to-latest.ts - Ensure tires aliases exist

Testing Checklist

  • curl /health shows both indices
  • curl /api/search?category=tires returns 7091 results
  • curl /api/filters?category=tires returns facets
  • Parts search still works (no regression)

On this page