Skip to content

feat: add is_endangered filter to Algolia search #436

@zigzagdev

Description

@zigzagdev

Summary / 概要

Add a boolean filter on endangered status (is_endangered) to the Algolia search.
Algolia 検索に危機遺産 (is_endangered) による boolean フィルタを追加する。

Why / 背景

The "List of World Heritage in Danger" is a recurring topic on the certification exam. The is_endangered column already propagates up to the DTO, but is not exposed as a search filter axis. The "skim through endangered heritage during my commute" study flow is therefore unavailable today.
検定では「危機遺産リストに登録されているもの」というジャンルが定番。現状 is_endangered カラムは DTO まで伝播しているが、検索の絞り込み軸として露出していない。「危機遺産だけ通勤中にざっと眺める」という学習動線が無い。

Changes / 対応内容

Application layer

  • Add public readonly ?bool $isEndangered to AlgoliaSearchListQuery (null = unspecified, true = endangered only, false = non-endangered only).
    AlgoliaSearchListQuerypublic readonly ?bool $isEndangered を追加(null = 指定なし、true = 危機遺産のみ、false = 危機遺産以外のみ)。
  • Add ?bool $isEndangered argument to AlgoliaSearchListQueryFactory::build().
    AlgoliaSearchListQueryFactory::build()?bool $isEndangered 引数を追加。

Domain / Infrastructure

  • In the WorldHeritageSearchPort implementation's search(), when isEndangered !== null, append is_endangered:true|false to facetFilters.
    WorldHeritageSearchPort 実装の search()isEndangered !== null のとき facetFiltersis_endangered:true|false を付与。
  • Add is_endangered to the attributesForFaceting of the Algolia index settings.
    Algolia インデックス設定の attributesForFacetingis_endangered を追加。

Presentation

  • Accept the is_endangered query parameter in the search endpoint Controller / FormRequest. Validation: boolean; null when unspecified.
    Search エンドポイントの Controller / FormRequest で is_endangered クエリパラメータを受ける(バリデーション: boolean、未指定時は null)。

Tests

  • AlgoliaSearchListQueryFactoryTest: true / false / null are stored correctly on the DTO across the three cases.
    AlgoliaSearchListQueryFactoryTest: true / false / null の 3 パターンが DTO に正しく入る。
  • Unit test for the search port: facetFilters is built as expected for each value.
    Search Port の単体テスト: 各値で facetFilters の組まれ方が期待通り。
  • Feature: GET /api/search?is_endangered=true returns endangered heritage only.
    Feature: GET /api/search?is_endangered=true で危機遺産のみ返る。

Acceptance / 受け入れ条件

  • is_endangered=true returns endangered heritage only; false returns non-endangered heritage only; unspecified returns all records as before.
  • An invalid value (e.g. is_endangered=foo) returns HTTP 400.
  • is_endangered=true で危機遺産のみ、false で非危機遺産のみ、未指定で従来通り全件。
  • 不正値(例: is_endangered=foo)は 400。

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions