Skip to content

fix: remove dead Algolia filter and restrict search response payload / Algolia検索の無駄なフィルタ・レスポンス削減 - #577

Open
zigzagdev wants to merge 2 commits into
mainfrom
fix/algolia-search-adapter-cleanup
Open

fix: remove dead Algolia filter and restrict search response payload / Algolia検索の無駄なフィルタ・レスポンス削減#577
zigzagdev wants to merge 2 commits into
mainfrom
fix/algolia-search-adapter-cleanup

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

An investigation into the search implementation found two low-risk, no-behavior-change cleanups in AlgoliaWorldHeritageSearchAdapter. Both were verified directly against the live (dev) Algolia index before fixing.

検索実装の調査で、AlgoliaWorldHeritageSearchAdapterに挙動を変えない低リスクな無駄を2件見つけました。修正前に実際のAlgoliaインデックス(dev用)に対してクエリを投げて事実確認しています。

What I have done / 実施内容

  • Removed the state_party:"..." clause from buildCountryOrFilter(). state_party is never indexed (confirmed: AlgoliaImportWorldHeritages never pushes such a field), and querying it directly against the live index returns 0 hits with no error — it's dead weight sent on every country-name search.
  • Added attributesToRetrieve: ['objectID', 'id'] to the searchSingleIndex call. Only the id is ever read from the response (WorldHeritageQueryService::searchHeritages re-fetches the full record from MySQL via findByIdsPreserveOrder), so the rest of each hit's fields were fetched from Algolia and immediately discarded.

Test Results / テスト結果

  • test_search_builds_algolia_params_with_filters_and_paging
  • test_search_by_country_name_without_iso3_does_not_filter_on_state_party

Full WorldHeritage-related suite (64 tests) also re-run with no regressions.

@github-actions github-actions Bot added bug Something isn't working backend release labels Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.99%. Comparing base (905138c) to head (1b88f2e).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #577      +/-   ##
============================================
+ Coverage     64.66%   64.99%   +0.33%     
- Complexity     1694     1695       +1     
============================================
  Files           147      147              
  Lines          8858     8894      +36     
============================================
+ Hits           5728     5781      +53     
+ Misses         3130     3113      -17     
Files with missing lines Coverage Δ
...tage/Adapter/AlgoliaWorldHeritageSearchAdapter.php 84.70% <100.00%> (+20.00%) ⬆️
...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.

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 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant