feat(search): Suchseite und Sofortsuche im Seitenkopf (#19, #60) #61

Closed
csaeum wants to merge 0 commits from feature/suche-overlay into main
Owner

Setzt #19 und #60 um — die Suchseite auf dem Index aus #58 und die Sofortsuche im Kopf jeder Seite. Der Zweig baut auf feature/suchseite auf; beide Issues liegen deshalb in einem Pull Request.

Was drin ist

Bereich Inhalt
Adresse routes.search je Sprache, SearchRouteLoader (Priorität 10) für Seite und …/suggest
Zustand SearchQuery, SearchQueryFactory — q, page (Produkte), cpage (Inhalte)
Abfrage SearchGroup, IndexSchema::searchBody(), Searcher — eine Abfrage je Gruppe über den Alias
Ergebnis SearchHit, SearchResultGroup, SearchResults, SearchResultUrls
Seite SearchPageController, pages/search.html.twig, search/form.html.twig
Sofortsuche SearchSuggestController, search/overlay.html.twig, SearchScriptExtension
Konfiguration search.results_per_page (12), search.suggestions_per_group (5)

Entscheidungen, jede am laufenden System belegt

  • Kein Preis in der Trefferliste. Der Index führt keine Preise (#58), und die Shop-API kann eine Menge bestimmter Produkte nicht in einem Aufruf liefern: ?code=, ?code[]= und ?code[in][]= werden stillschweigend übergangen und liefern unverändert alle 87 Produkte. Einzelabrufe kosten bei kaltem Katalog-Cache ~150 ms je Treffer.
  • Zwei Seitenzahlen, weil es zwei Gruppen gibt — Blättern in den Produkten darf die Inhalte nicht verschieben.
  • Der Fliesstext kommt nicht zurück; highlight liefert den getroffenen Ausschnitt, und nur wo kein gepflegter Teaser existiert. Ohne Hervorhebung, damit kein Index-Inhalt als HTML ausgegeben werden muss.
  • Ausfall ist eine eigene Auskunft: Die Seite antwortet mit 503, nie mit „keine Treffer". Im Seitenkopf bleibt derselbe Ausfall unsichtbar — dort hat niemand gesucht.
  • Der Suggest-Endpunkt ist ein Geschwister der Suchseite, keine feste Route: nur so löst Sulu Webspace und Sprache über denselben Weg auf wie bei der Seite.
  • Kein Cache für Suchergebnisse, no-store und private für die Sofortsuche.
  • Das Skript kommt einmal je Anfrage, auch wenn das Formular zweimal auf der Seite steht.
  • Ein Treffer ohne gültige Art oder ohne Slug wird ausgelassen statt geraten.

Prüfung

php-cs-fixer, PHPStan Level 8 und 385 Tests grün — ohne OpenSearch, ohne Shop, ohne Datenbank. Die Seiten-Tests rendern die echten Templates des Bundles.

Im DDEV gegen den laufenden OpenSearch und sylius-shop:

Prüfung Ergebnis
?q=caps 18 Treffer: 12 Produktkacheln + Seite „Caps"
?q=caps&page=2 5 Kacheln, Seite 2 markiert, cpage bleibt stehen
?q=shop Inhalte-Gruppe, Ausschnitt statt fehlendem Teaser
?q=jens die echten Jeans
?q=j / ?q=gibtesnichtxyz Mindestlänge-Hinweis ohne Indexabfrage / „nichts gefunden"
OpenSearch gestoppt 503 mit Störungsmeldung
/shop-search/suggest?q=caps JSON in 30–60 ms, no-store, private, fertige Adressen
Kopf auf /, /caps, /shop, /p/… Formular, Skript und Endpunkt-Adresse überall
Suchseite zwei Formulare, ein Skriptblock

Das Overlay wurde von Hand im Browser geprüft.

Offen (bewusst ausserhalb)

  • Der Artikel-Pfad ist nicht real gelaufen — das Testprojekt enthält keine Artikel
  • Im Testprojekt liegt die Suchseite auf shop-search, weil /search bereits eine Seite des Theme-Bundles ist; Sulus eigener Route-Loader gewinnt dort wie vorgesehen

closes #19
closes #60

🤖 Generated with Claude Code

Setzt **#19** und **#60** um — die Suchseite auf dem Index aus #58 und die Sofortsuche im Kopf jeder Seite. Der Zweig baut auf `feature/suchseite` auf; beide Issues liegen deshalb in einem Pull Request. ## Was drin ist | Bereich | Inhalt | |---|---| | Adresse | `routes.search` je Sprache, `SearchRouteLoader` (Priorität 10) für Seite **und** `…/suggest` | | Zustand | `SearchQuery`, `SearchQueryFactory` — `q`, `page` (Produkte), `cpage` (Inhalte) | | Abfrage | `SearchGroup`, `IndexSchema::searchBody()`, `Searcher` — eine Abfrage je Gruppe über den Alias | | Ergebnis | `SearchHit`, `SearchResultGroup`, `SearchResults`, `SearchResultUrls` | | Seite | `SearchPageController`, `pages/search.html.twig`, `search/form.html.twig` | | Sofortsuche | `SearchSuggestController`, `search/overlay.html.twig`, `SearchScriptExtension` | | Konfiguration | `search.results_per_page` (12), `search.suggestions_per_group` (5) | ## Entscheidungen, jede am laufenden System belegt - **Kein Preis in der Trefferliste.** Der Index führt keine Preise (#58), und die Shop-API kann eine Menge bestimmter Produkte nicht in einem Aufruf liefern: `?code=`, `?code[]=` und `?code[in][]=` werden stillschweigend übergangen und liefern unverändert alle 87 Produkte. Einzelabrufe kosten bei kaltem Katalog-Cache ~150 ms je Treffer. - **Zwei Seitenzahlen**, weil es zwei Gruppen gibt — Blättern in den Produkten darf die Inhalte nicht verschieben. - **Der Fliesstext kommt nicht zurück**; `highlight` liefert den getroffenen Ausschnitt, und nur wo kein gepflegter Teaser existiert. Ohne Hervorhebung, damit kein Index-Inhalt als HTML ausgegeben werden muss. - **Ausfall ist eine eigene Auskunft**: Die Seite antwortet mit **503**, nie mit „keine Treffer". Im Seitenkopf bleibt derselbe Ausfall unsichtbar — dort hat niemand gesucht. - **Der Suggest-Endpunkt ist ein Geschwister der Suchseite**, keine feste Route: nur so löst Sulu Webspace und Sprache über denselben Weg auf wie bei der Seite. - **Kein Cache für Suchergebnisse**, `no-store` und `private` für die Sofortsuche. - **Das Skript kommt einmal je Anfrage**, auch wenn das Formular zweimal auf der Seite steht. - Ein Treffer ohne gültige Art oder ohne Slug wird **ausgelassen statt geraten**. ## Prüfung php-cs-fixer, PHPStan Level 8 und **385 Tests** grün — ohne OpenSearch, ohne Shop, ohne Datenbank. Die Seiten-Tests rendern die echten Templates des Bundles. Im DDEV gegen den laufenden OpenSearch und `sylius-shop`: | Prüfung | Ergebnis | |---|---| | `?q=caps` | 18 Treffer: 12 Produktkacheln + Seite „Caps" | | `?q=caps&page=2` | 5 Kacheln, Seite 2 markiert, `cpage` bleibt stehen | | `?q=shop` | Inhalte-Gruppe, Ausschnitt statt fehlendem Teaser | | `?q=jens` | die echten Jeans | | `?q=j` / `?q=gibtesnichtxyz` | Mindestlänge-Hinweis ohne Indexabfrage / „nichts gefunden" | | OpenSearch gestoppt | 503 mit Störungsmeldung | | `/shop-search/suggest?q=caps` | JSON in 30–60 ms, `no-store, private`, fertige Adressen | | Kopf auf `/`, `/caps`, `/shop`, `/p/…` | Formular, Skript und Endpunkt-Adresse überall | | Suchseite | zwei Formulare, **ein** Skriptblock | Das Overlay wurde von Hand im Browser geprüft. ## Offen (bewusst ausserhalb) - Der **Artikel**-Pfad ist nicht real gelaufen — das Testprojekt enthält keine Artikel - Im Testprojekt liegt die Suchseite auf `shop-search`, weil `/search` bereits eine Seite des Theme-Bundles ist; Sulus eigener Route-Loader gewinnt dort wie vorgesehen closes #19 closes #60 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Serves the configured slug through an own route loader and answers with two
separate groups: products as tiles, content as title and teaser. Each group
pages on its own (`page` and `cpage`) - paging the products must not move the
paragraph someone is reading.

Decisions measured against the running system:

- No price in the result list. The index carries none, and the shop API cannot
  deliver a set of given products in one call: `?code=`, `?code[]=` and
  `?code[in][]=` are silently ignored and return all 87 products. Fetching them
  one by one costs ~150 ms each on a cold catalog cache.
- The long text stays out of the response; `highlight` delivers the matched
  excerpt, and only where no maintained teaser exists. Highlighting is off, so
  the template never has to output index content as HTML.
- A failing index answers 503, never an empty result list - claiming there is
  nothing is the one answer nobody can verify.
- A hit without a valid type or slug is dropped instead of guessed.

Control characters in the term are removed rather than replaced by a space:
`jea<NUL>ns` would otherwise fall apart into two words that do not exist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
docs(search): describe the search page and its four states
All checks were successful
CI / phpstan (push) Successful in 2m33s
CI / phpunit (push) Successful in 31s
CI / cs-check (push) Successful in 23s
CI / build-release (push) Has been skipped
0acd1f1e72
Records what cannot be read from the code: why the address sits next to the
shop markers, why two page numbers, why no price in the result list, and what
the failure state costs (3.2 s until the configured timeout).

Also documents two traps from the test project: `/search` is already a page of
the theme bundle and wins over the bundle's route loader, and the test webspace
runs without a language prefix on `en`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Shows the top hits while someone types, products and pages apart, with a link
to the full result page. The form stays a plain GET form: without JavaScript,
on a slow line or while the index is down, Enter still leads to the result page
from #19.

The endpoint is a sibling of the search page (`<slug>/suggest`) rather than a
fixed Symfony route. That way Sulu resolves webspace and locale through the
same path as the page itself - a fixed route would have to derive the webspace
from the host name, a second place for the same value.

Notable details:

- The answer carries finished addresses, resolved by `SearchResultUrls`, which
  the template now shares. The script knows neither marker segments nor
  language prefixes.
- No cache, `no-store` and `private`: search terms are a long tail, a cache
  would almost never hit and would keep typos instead.
- A disturbed index answers 503 with a valid empty payload; the overlay simply
  stays closed and the page header is none the wiser.
- `SearchScriptExtension` delivers the script once per request. The form may
  appear twice on a page, and the in-script guard only prevents double
  execution, not double transfer.
- The script renders through `textContent`, accepts only addresses starting
  with `/`, and aborts a superseded request.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
docs(search): explain the instant search and how to embed it
All checks were successful
CI / cs-check (push) Successful in 22s
CI / phpstan (push) Successful in 38s
CI / phpunit (push) Successful in 31s
CI / build-release (push) Has been skipped
57283e1c47
The README now carries the embedding code itself, for a plain layout and for a
page inheriting a theme's header, together with the variables the form accepts
and the shape of the JSON answer.

Architecture notes record why the endpoint sits under the search page, why
there is no cache, and why the script is delivered once per request rather than
once per form.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
csaeum closed this pull request 2026-09-17 19:25:38 +00:00
All checks were successful
CI / cs-check (push) Successful in 22s
CI / phpstan (push) Successful in 38s
CI / phpunit (push) Successful in 31s
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!61
No description provided.