Skip to content

fix: use optionalFilters for unresolved countryName in Algolia search / 未解決countryNameをoptionalFiltersに変更 - #602

Merged
zigzagdev merged 2 commits into
fix/algolia-search-adapter-design-gapsfrom
fix/algolia-country-name-optional-filter
Oct 24, 2026
Merged

zigzagdev merged 2 commits into
fix/algolia-search-adapter-design-gapsfrom
fix/algolia-country-name-optional-filter

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

The countryName branch (reached only when countryIso3 did not resolve)
added its country OR-filter to the mandatory $filters array. Because
$filters entries are AND-ed together, an input that doesn't match a
real country (e.g. "Jap") excluded every record and returned 0 results,
even though the surrounding comment said the opposite was intended
("full-text search should still work for an unresolved country term").

countryName分岐(countryIso3が解決できなかった場合のみ到達)が、国名の
OR-filterを必須の$filters配列に追加していました。$filtersはAND結合
されるため、実在しない国名(例: "Jap")を渡すと全件が除外されて0件に
なっていました。コメントには「解決できない国名でも全文検索は動く」と
書かれていましたが、実装はそれを実現していませんでした。

What I have done / 実施内容

  • Introduced $optionalFilters, which boosts matching records instead of
    excluding non-matching ones
  • Moved the countryName branch's buildCountryOrFilter() result from
    $filters[] to $optionalFilters[]
  • Added 'optionalFilters' => $optionalFilters to the searchSingleIndex()
    call
  • Extended the empty-result guardrail to also treat a non-empty
    $optionalFilters as real search criteria (otherwise a country-name-only
    query with no keyword would incorrectly short-circuit to 0 results)
  • Updated the existing country-name test to expect optionalFilters
    instead of filters, and added two new tests

Test Results / テスト結果

  • AlgoliaWorldHeritageSearchAdapterTest: 5 passed
  • php artisan test (full suite): 220 passed, no regressions

Closes #595
Part of #592

The countryName branch (reached only when countryIso3 did not resolve)
added its OR-filter to the mandatory $filters array, so an input that
doesn't match a real country (e.g. "Jap") excluded every record instead
of falling back to full-text search, even though the surrounding comment
said the opposite was intended.

Move it to $optionalFilters, which boosts matching records instead of
excluding non-matching ones, and extend the empty-result guardrail to
also treat a non-empty $optionalFilters as real search criteria.
…ageSearchAdapterTest

- country-name-only search now expects optionalFilters, not filters
- lowercase country name still builds the optional OR-filter
- an unresolvable country term (e.g. a 3-letter non-country word) no
  longer short-circuits to an empty result via the adapter's own
  guardrail
@github-actions github-actions Bot added bug Something isn't working backend labels Oct 24, 2026
@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.75%. Comparing base (2c43727) to head (66311ae).

Additional details and impacted files

Impacted file tree graph

@@                             Coverage Diff                              @@
##             fix/algolia-search-adapter-design-gaps     #602      +/-   ##
============================================================================
+ Coverage                                     67.47%   67.75%   +0.28%     
- Complexity                                     1709     1713       +4     
============================================================================
  Files                                           149      149              
  Lines                                          8999     9072      +73     
============================================================================
+ Hits                                           6072     6147      +75     
+ Misses                                         2927     2925       -2     
Files with missing lines Coverage Δ
...tage/Adapter/AlgoliaWorldHeritageSearchAdapter.php 87.35% <100.00%> (+2.83%) ⬆️
...ge/Tests/AlgoliaWorldHeritageSearchAdapterTest.php 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zigzagdev zigzagdev self-assigned this Oct 24, 2026
@zigzagdev zigzagdev linked an issue Oct 24, 2026 that may be closed by this pull request
4 tasks

@zigzagdev zigzagdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@zigzagdev
zigzagdev merged commit 2988b89 into fix/algolia-search-adapter-design-gaps Oct 24, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change countryName branch filter from filters to optionalFilters

1 participant