Skip to content

feat: bring custom analyzer definitions (add_analyzer / TOML schema I/O) to laurus-ruby, laurus-nodejs, and laurus-wasm #1062

Description

@mosuka

Summary

#1058 added Schema.add_analyzer / Schema.from_toml / Schema.from_toml_file / Schema.to_toml / Schema.to_toml_file to laurus-python, letting Python callers register a custom AnalyzerDefinition (char filters + tokenizer + token filters) and load/save the same TOML format laurus-cli create index --schema accepts. No other language binding has equivalent functionality yet:

  • laurus-ruby's docs/comments reference an add_analyzer that does not exist yet.
  • laurus-nodejs's Schema already accepts a serde_json::Value directly for related config (see laurus-nodejs/src/schema.rs), so it may be able to reuse the exact same JSON shape laurus-python uses ({"type": "...", ...} per component) with comparatively little new code.
  • laurus-wasm's existing add_analyzer is an unrelated, different concept (it registers a runtime WasmJapaneseAnalyzer object, not an AnalyzerDefinition) and would need a distinct API rather than a direct port.

Suggested direction

For each binding, evaluate and implement (as separate PRs, likely tracked as sub-issues of this one):

  1. laurus-nodejs: add add_analyzer/from_toml/from_toml_file/to_toml/to_toml_file (or the binding's idiomatic equivalent), reusing the laurus-python implementation's JSON shape and error-handling approach (see feat(python): support custom analyzer definitions and TOML schema loading in laurus-python #1058's PR description for the design rationale, e.g. why tokenizer is required and filters are optional/keyword-only in Python — evaluate whether the same reasoning applies to Node's calling conventions).
  2. laurus-ruby: same, adapted to Ruby idioms (e.g. keyword arguments), and fix the stale doc/comment reference to a not-yet-implemented add_analyzer.
  3. laurus-wasm: design a distinct API (its existing add_analyzer name is already taken by an unrelated concept), or pick a different method name to avoid confusion.

Decision (2026-09-17)

After investigation, a blocker was found: core's Schema::from_toml/to_toml are #[cfg(not(target_arch = "wasm32"))]-gated, so laurus-wasm cannot call them as-is. Decision: lift the core wasm32 gate (verified against an actual wasm32 build) and deliver all three bindings (Ruby, Node.js, WASM) together in a single PR rather than splitting WASM into a follow-up issue. The new WASM method is named addAnalyzerDefinition to avoid colliding with the existing, unrelated addAnalyzer. Full rationale in the investigation/plan comment below.

Acceptance criteria

  • laurus-ruby, laurus-nodejs, and laurus-wasm all have feature parity with laurus-python's Schema.add_analyzer/TOML I/O.
  • Stale documentation referencing a not-yet-implemented add_analyzer (e.g. in laurus-ruby) is corrected or resolved.

Task list

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions