Skip to content

Multi-language search crashes with "index out of bounds" when using 3+ indexed fields #3098

@welpo

Description

@welpo

Bug Report

Environment

Zola version: 0.22.1 (also affects current next branch)

Expected Behavior

When building a multi-language site with search enabled and multiple indexed fields (title, description, path, content), the build should complete successfully and generate search indexes for all configured languages.

Example output:

Building site...
-> Creating 76 pages (0 orphan) and 19 sections
Done in 1.7s.

Search indexes created:

  • public/search_index.en.js
  • public/search_index.es.js

Current Behavior

Build crashes with an index out of bounds panic:

Building site...
-> Creating 76 pages (0 orphan) and 19 sections

thread 'main' panicked at elasticlunr-rs-3.0.2/src/lib.rs:317:37:
index out of bounds: the len is 2 but the index is 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Example GH action run: https://github.com/welpo/tabi/actions/runs/21471469174/job/61846221224

Steps to Reproduce

Minimal Configuration

Create a config.toml with:

base_url = "https://example.com"
build_search_index = true

default_language = "en"

[search]
include_title = true
include_description = true
include_path = true
include_content = true

[languages.es]
build_search_index = true

Content Structure

content/
  _index.md
  blog/
    _index.md
    post.md
    post.es.md

Run

zola build

Result

Panic with "index out of bounds: the len is 2 but the index is 2"

Additional context

This is a regression:

  • ✅ Zola v0.22.0: Works correctly
  • ❌ Zola v0.22.1: Broken
  • ❌ Current next branch: Broken

Introduced in: PR #3085 (commit 790de70)

Root cause: Configuration mismatch in components/search/src/elasticlunr.rs where build_fields() uses language_options.search but fill_index() uses config.search, causing field count mismatch when building indexes for non-default languages.

Workarounds:

  1. Use only 2 indexed fields (title + content):

    [search]
    include_title = true
    include_description = false
    include_path = false
    include_content = true
  2. Disable multi-language search:

    [languages.es]
    build_search_index = false
  3. Downgrade to v0.22.0


Creating PR to fix this soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions