feat(search): Suchindex für Produkte und Sulu-Inhalte (#58) #59

Closed
csaeum wants to merge 0 commits from feature/suchindex-opensearch into main
Owner

Setzt #58 vollständig um: einen OpenSearch-Index, der Shop-Produkte und Sulu-Inhalte
als Dokumente eines Index führt, samt Befehlen und laufender Aktualisierung. Grundlage
der Suchseite aus #19.

Was drin ist

Bereich Inhalt
Schema IndexSchema, IndexNames, OpenSearchClient, IndexManager, SearchTargets
Produkte ProductDocumentFactory, TaxonNameResolver, ProductIndexer
Inhalte ContentDocumentFactory, ContentIndexer
Aktualisierung DocumentWriter, ContentChangeListener, WebhookSignature, SearchWebhookController
Befehle wsc:sylius:search:index-create, wsc:sylius:search:reindex
Konfiguration Zweig search (Adresse, Analyzer, live_updates, webhook_secret)

Entscheidungen, jede am laufenden System gemessen

  • Ein Index je Webspace und Sprache — der Analyzer steht im Mapping fest und ist
    sprachgebunden.
  • Gesucht wird über einen Alias, geschrieben in einen Index mit Zeitstempel: Der
    Neuaufbau füllt erst und hängt dann um, es gibt keine Suchlücke.
  • dynamic: strict — ein unbekanntes Feld bricht den Lauf ab, statt still ein Feld
    anzulegen.
  • Im Dokument steht der Slug, nie eine fertige Adresse: Präfix und Host kommen erst zur
    Anzeige, ein umgebauter Webspace entwertet den Index nicht.
  • Keine Preise — die kommen live aus der Shop-API.
  • Kategorien über je eine gefilterte Produktliste (3 s) statt über productTaxons je
    Produkt (29 s).
  • Positivliste für den Seitentext: In den Blockdaten stehen Theme-Einstellungen
    (mt-5, one_column) gleichberechtigt neben dem Text.
  • Inhalte werden beim Ereignis neu geladen — die Entität aus dem Ereignis trägt ihre
    Route nicht zwingend, die Seite verschwand dadurch beim Veröffentlichen lautlos aus dem
    Index.
  • Ein Ausfall des Index blockiert nie den Betrieb: Fehler werden protokolliert und
    verschluckt.
  • Die Meldung des Shops ist signiert (HMAC über Zeitstempel und Rumpf, hash_equals,
    fünf Minuten Fenster). Ohne Geheimnis ist der Endpunkt aus und antwortet mit 404.

Prüfung

  • php-cs-fixer, PHPStan Level 8 und 319 Tests grün — ohne OpenSearch, ohne Shop, ohne
    Datenbank
  • Im DDEV gegen den laufenden sylius-shop: voller Lauf 87 Produkte und 6 Seiten in
    4,0 s je Sprache
    ; jens findet die echten Jeans, shrit die T-Shirts, handverlesn
    eine Seite über ihren Fliesstext; publish/unpublish bewegen den Index 6 → 5 → 6;
    Webhook liefert 200 / 401 / 400 / 404 wie vorgesehen

Offen (bewusst ausserhalb)

  • Der Sender im Sylius-Bundle: Sylius-Bundles/wsc_syliusbundle_suluintegration #18
  • Der Artikel-Pfad ist nicht real gelaufen — das Testprojekt enthält keine Artikel
  • Das Kriterium „Ausfall verständlich anzeigen" ist an #19 übergeben, dort steht es
    bereits

closes #58

🤖 Generated with Claude Code

Setzt **#58** vollständig um: einen OpenSearch-Index, der Shop-Produkte und Sulu-Inhalte als Dokumente **eines** Index führt, samt Befehlen und laufender Aktualisierung. Grundlage der Suchseite aus #19. ## Was drin ist | Bereich | Inhalt | |---|---| | Schema | `IndexSchema`, `IndexNames`, `OpenSearchClient`, `IndexManager`, `SearchTargets` | | Produkte | `ProductDocumentFactory`, `TaxonNameResolver`, `ProductIndexer` | | Inhalte | `ContentDocumentFactory`, `ContentIndexer` | | Aktualisierung | `DocumentWriter`, `ContentChangeListener`, `WebhookSignature`, `SearchWebhookController` | | Befehle | `wsc:sylius:search:index-create`, `wsc:sylius:search:reindex` | | Konfiguration | Zweig `search` (Adresse, Analyzer, `live_updates`, `webhook_secret`) | ## Entscheidungen, jede am laufenden System gemessen - **Ein Index je Webspace und Sprache** — der Analyzer steht im Mapping fest und ist sprachgebunden. - **Gesucht wird über einen Alias, geschrieben in einen Index mit Zeitstempel**: Der Neuaufbau füllt erst und hängt dann um, es gibt keine Suchlücke. - **`dynamic: strict`** — ein unbekanntes Feld bricht den Lauf ab, statt still ein Feld anzulegen. - **Im Dokument steht der Slug, nie eine fertige Adresse**: Präfix und Host kommen erst zur Anzeige, ein umgebauter Webspace entwertet den Index nicht. - **Keine Preise** — die kommen live aus der Shop-API. - **Kategorien über je eine gefilterte Produktliste** (3 s) statt über `productTaxons` je Produkt (29 s). - **Positivliste für den Seitentext**: In den Blockdaten stehen Theme-Einstellungen (`mt-5`, `one_column`) gleichberechtigt neben dem Text. - **Inhalte werden beim Ereignis neu geladen** — die Entität aus dem Ereignis trägt ihre Route nicht zwingend, die Seite verschwand dadurch beim Veröffentlichen lautlos aus dem Index. - **Ein Ausfall des Index blockiert nie den Betrieb**: Fehler werden protokolliert und verschluckt. - **Die Meldung des Shops ist signiert** (HMAC über Zeitstempel und Rumpf, `hash_equals`, fünf Minuten Fenster). Ohne Geheimnis ist der Endpunkt aus und antwortet mit 404. ## Prüfung - php-cs-fixer, PHPStan Level 8 und **319 Tests** grün — ohne OpenSearch, ohne Shop, ohne Datenbank - Im DDEV gegen den laufenden `sylius-shop`: voller Lauf **87 Produkte und 6 Seiten in 4,0 s je Sprache**; `jens` findet die echten Jeans, `shrit` die T-Shirts, `handverlesn` eine Seite über ihren Fliesstext; `publish`/`unpublish` bewegen den Index 6 → 5 → 6; Webhook liefert 200 / 401 / 400 / 404 wie vorgesehen ## Offen (bewusst ausserhalb) - Der **Sender** im Sylius-Bundle: `Sylius-Bundles/wsc_syliusbundle_suluintegration` #18 - Der **Artikel**-Pfad ist nicht real gelaufen — das Testprojekt enthält keine Artikel - Das Kriterium „Ausfall verständlich anzeigen" ist an **#19** übergeben, dort steht es bereits closes #58 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The search was planned: #19 now describes the page for products and
content, #58 the OpenSearch index behind it, and #19 depends on #58.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Step 1 of #58 is done in the test project: the ddev-opensearch add-on
runs at http://opensearch:9200, pinned to 3.8.0. A throwaway index
confirmed that the german analyzer with fuzziness AUTO carries every
acceptance case before any PHP is written.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds a site search index that holds shop products and Sulu content as
documents of one index per webspace and locale, plus the commands and the
event handling that keep it current.

Why OpenSearch and not the existing tools: the shop API only filters
translations.name as a substring, and Seal passes no fuzziness to its
adapters, so "jens" never finds "Jeans" (measured 2026-09-15, see #58).

Key decisions, each measured against the running test shop:

- One index per webspace and locale, because the analyzer is fixed in the
  mapping and is language bound.
- Search goes through an alias, writing goes into a timestamped index, so
  a rebuild can fill before it switches and never serves a half index.
- Mapping is strict: an unknown field aborts the run instead of silently
  creating a field nobody notices until the search comes up empty.
- Documents carry the slug, never a finished URL: the route generator
  needs a request for prefix and host, and a rebuilt webspace would
  invalidate stored addresses.
- No prices in the index; they are read live from the shop API.
- Categories come from one filtered product list per taxon (3 s) instead
  of resolving productTaxons per product (29 s).
- Page and article text is collected through a positive list of keys,
  since theme settings such as mt-5 or one_column sit next to the text.
- Content updates ride on Sulu's own publish events and reload the entity
  from the repository, because the event's entity may carry no route.
- Product changes arrive over a signed webhook; without a secret the
  endpoint is off and answers 404.
- A failing index never blocks editing: errors are logged and swallowed.

Tests run without OpenSearch, without a shop and without a database.

Refs #58

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
setup.md: the OpenSearch service, the index and reindex commands with the
measured runtime, what a document holds, how live updates and the signed
webhook are set up, and the nightly rebuild as a safety net.

architecture.md: why an own index instead of the shop API or Seal, why one
index per language, how the alias switch works, how page text is told apart
from theme settings, and why an index failure must never block editing.

Also corrects the local verification commands in both setup.md and
CICD-Actions.md: they named a BUNDLE_DIR variable that does not exist in the
container, so the documented commands aborted with "unbound variable".

Refs #58

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
docs(status): record the finished search index and the next step (#58)
All checks were successful
CI / cs-check (push) Successful in 28s
CI / phpstan (push) Successful in 45s
CI / phpunit (push) Successful in 38s
CI / build-release (push) Has been skipped
ee92b25661
The index work is committed and #58 is closed; the handover now points at
#19, the search page, and carries the criterion that moved there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
csaeum closed this pull request 2026-09-17 18:10:33 +00:00
All checks were successful
CI / cs-check (push) Successful in 28s
CI / phpstan (push) Successful in 45s
CI / phpunit (push) Successful in 38s
CI / build-release (push) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Sulu-Bundles/wsc_sulubundle_syliusheadless!59
No description provided.