Skip to content

feat: manage Algolia attributesForFaceting as code / Algoliaのattributesforfacetingをコードで管理 - #603

Merged
zigzagdev merged 6 commits into
fix/algolia-search-adapter-design-gapsfrom
fix/algolia-sync-index-settings
Oct 25, 2026
Merged

zigzagdev merged 6 commits into
fix/algolia-search-adapter-design-gapsfrom
fix/algolia-sync-index-settings

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

attributesForFaceting (the Algolia index settings that control which attributes can be
filtered/faceted) were only ever configured manually in the Algolia dashboard. Nothing in
this repo could reproduce or verify them.

attributesForFaceting(Algoliaのインデックス設定のうち、どの属性をfilter/facetできるかを決める設定)は
ダッシュボードで手動設定されたままで、このリポジトリのどこにも再現・検証する手段がありませんでした。

Investigated whether this currently causes real filtering errors (the issue's stated
"Current Problem"): it does not. Every attribute AlgoliaWorldHeritageSearchAdapter actually
uses in $filters/$optionalFilters is already declared live (confirmed via getSettings()
against the real index), and the numeric year_inscribed range filter does not require
attributesForFaceting at all (confirmed by running it against the real index). The remaining,
real gap is that these settings exist only in the dashboard, not as code.

これが実際にフィルタエラーを起こしているか(Issueの"Current Problem")を調査した結果、起きていません。
Adapterが$filters/$optionalFiltersで実際に使っている属性はすべて既にライブ環境に登録済みで
(getSettings()で確認)、数値範囲フィルタのyear_inscribedはそもそもattributesForFacetingを必要とせず
動作することも実際のインデックスへの呼び出しで確認しました。残っている実際の問題は、設定がコードとして
存在していないことだけです。

What I have done / 実施内容

  • Added App\Console\Commands\AlgoliaSyncIndexSettings (algolia:sync-index-settings,
    supports --dry-run) that applies attributesForFaceting from a code constant
    (AlgoliaSyncIndexSettings::ATTRIBUTES_FOR_FACETING) to the Algolia index
  • Set the constant to match what is currently live, so running the command is a no-op change
    in production
  • Documented the decision in app/Packages/Domains/README.md, including that
    country_names_jp / region / study_regions are candidates for filterOnly() since the
    Adapter does not filter on them, but this is deliberately deferred pending confirmation of
    whether the frontend relies on their facet counts
  • Did not run the command against the live index as part of this PR (kept it at the
    code+test stage)

Test Results / テスト結果

  • AlgoliaSyncIndexSettingsTest: 2 passed
    • test_dry_run_prints_attributes_for_faceting_without_calling_algolia
    • test_attributes_for_faceting_covers_every_attribute_the_adapter_filters_on
  • php artisan test (full suite): 222 passed, no regressions

Closes #598
Part of #592

@github-actions github-actions Bot added bug Something isn't working backend labels Oct 24, 2026
@zigzagdev zigzagdev self-assigned this Oct 25, 2026
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.85057% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.05%. Comparing base (2988b89) to head (e236927).

Files with missing lines Patch % Lines
src/app/Providers/AppServiceProvider.php 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                             Coverage Diff                              @@
##             fix/algolia-search-adapter-design-gaps     #603      +/-   ##
============================================================================
+ Coverage                                     67.75%   68.05%   +0.29%     
- Complexity                                     1713     1731      +18     
============================================================================
  Files                                           149      153       +4     
  Lines                                          9072     9159      +87     
============================================================================
+ Hits                                           6147     6233      +86     
- Misses                                         2925     2926       +1     
Files with missing lines Coverage Δ
.../app/Console/Commands/AlgoliaSyncIndexSettings.php 100.00% <100.00%> (ø)
...rldHeritage/Adapter/AlgoliaIndexSettingsSyncer.php 100.00% <100.00%> (ø)
...dHeritage/Tests/AlgoliaIndexSettingsSyncerTest.php 100.00% <100.00%> (ø)
...rldHeritage/Tests/AlgoliaSyncIndexSettingsTest.php 100.00% <100.00%> (ø)
src/app/Providers/AppServiceProvider.php 37.50% <66.66%> (+4.16%) ⬆️
🚀 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 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.

LGTM

@zigzagdev
zigzagdev merged commit 84b835d into fix/algolia-search-adapter-design-gaps Oct 25, 2026
27 checks passed
@zigzagdev
zigzagdev deleted the fix/algolia-sync-index-settings branch October 25, 2026 06:18
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.

Confirm filterable attributes are declared in attributesForFaceting with filterOnly

1 participant