Skip to content

Multilingual card search (integrates #1 by @w-dan) - #5

Merged
madeofpendletonwool merged 6 commits into
mainfrom
pr1-multilingual-search
Jul 21, 2026
Merged

madeofpendletonwool merged 6 commits into
mainfrom
pr1-multilingual-search

Conversation

@madeofpendletonwool

Copy link
Copy Markdown
Owner

Integrates @w-dan's multilingual card search from #1, rebased onto current main with the merge conflict resolved and a few integration fixes.

All feature credit goes to @w-dan (Dani) — see #1 for the original work and write-up. Closes #1.

What the feature does

Cards can now be found by their foreign names (e.g. "Gegenzauber" or "対抗呪文" → Counterspell). The root cause was the import script reading fd.faceName, which MTGJSON only populates for multi-face cards, leaving foreign_name null for single-face cards; it now reads fd.name.

Conflict resolution (src/services/cardService.js)

searchCards() on main had since gained a typeFilter parameter (used by the price-watch card type filter via src/routes/cards.js). The PR was written against the older two-arg signature and dropped it, so merging as-is would have silently broken the card type filter.

  • Combined both: foreign-name matching and typeFilter.
  • Parenthesised the name-match OR group so the type filter ANDs against the whole group rather than only the last OR branch.
  • Dropped a redundant LIMIT 1 inside EXISTS().

Integration fixes

  • Index moved to its own migration. idx_foreign_name was added inside migration 010, which is already applied on existing installs — the runner would never re-run it, so only fresh databases would get the index. Now in 020-add-foreign-name-index.js using CREATE INDEX IF NOT EXISTS.
  • Removed 017-add-card-search-fts.js. It collided with the existing 017-add-price-watches.js, and the FTS5 table it created was never populated or queried. The original PR's own commit 5cac99c "Removed FTS search (found to be unnecessary)" had already dropped FTS usage but left the migration behind.

Notes for testing

The import-script change only takes effect after a card database re-import, so this needs a Docker run with a re-import to see multilingual results.

Two things worth knowing (both pre-existing, not regressions):

  • Search returns one row per printing, so a card with many printings can crowd out other matches under LIMIT.
  • Foreign matching uses EXISTS(... LIKE '%query%') joined on card_name = c.name, which can't use the new index; may be slow on a large card_foreign_data table.

w-dan and others added 6 commits December 26, 2025 22:56
- Updated import script to use fd.name instead of fd.faceName for foreign card names
- Added index on foreign_name for better search performance
- Modified searchCards to query card_foreign_data table
- Searches now work with Spanish, Japanese, German, French, etc. card names
- Fixed foreign name field
- Added index on foreign name + FTS fallback
Integrates w-dan's multilingual search so cards can be found by their
foreign names, resolved against current main.

Conflict resolution (src/services/cardService.js):
- searchCards() on main had gained a `typeFilter` param; the PR was written
  against an older signature and dropped it. Combined both: foreign-name
  matching AND the type filter, so the price-watch card type filter keeps
  working.
- Parenthesised the name-match OR group so the type filter ANDs against the
  whole group rather than only the last OR branch.
- Dropped redundant LIMIT 1 inside EXISTS().

Integration fixes:
- Moved the idx_foreign_name index out of migration 010 (already applied on
  existing installs, so it would never have run for them) into new migration
  020-add-foreign-name-index.js using CREATE INDEX IF NOT EXISTS.
- Removed 017-add-card-search-fts.js: it collided with the existing
  017-add-price-watches.js and created an FTS5 table that was never populated
  or queried (the PR's own 5cac99c had already dropped FTS as unnecessary).

Co-Authored-By: Dani <d.galgora@upm.es>
@madeofpendletonwool
madeofpendletonwool merged commit 78561f2 into main Jul 21, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants