Rule builder: facet-value typeahead for text fields (#176 follow-up) #434

Closed
opened 2026-07-18 01:50:36 +02:00 by timothy · 3 comments
Owner

Follow-up to #176 (visual rule builder, PR #433). Text-field values are free-text today; keyword-exact matching means a typo silently returns zero results (the live preview count is the current safety net).

Add a distinct-values endpoint GET /api/v1/search/fields/{name}/values?q= and turn text-field value inputs into autocomplete comboboxes. Purely additive: swap the input for a combobox in RuleBuilder; no change to compile/parse.

Done-when

  • adversarial review passed
  • endpoint + SPA combobox, docs + openapi regenerated
Follow-up to #176 (visual rule builder, PR #433). Text-field values are free-text today; keyword-exact matching means a typo silently returns zero results (the live preview count is the current safety net). Add a distinct-values endpoint `GET /api/v1/search/fields/{name}/values?q=` and turn text-field value inputs into autocomplete comboboxes. Purely additive: swap the input for a combobox in `RuleBuilder`; no change to compile/parse. ## Done-when - [x] adversarial review passed - [x] endpoint + SPA combobox, docs + openapi regenerated
timothy added the apipriority: lowfrontend labels 2026-07-18 01:50:36 +02:00
Author
Owner

🔗 Session bundle — rule builder (#176 follow-ups): #434, #435, #436, #437, #438

All frontend RuleBuilder follow-ups deferred from #176: facet-value typeahead (#434), relative-date operators (#435), deeper nesting (#436), inline adoption in ChannelBuilder & Auto-Tune (#437), input validation & polish (#438). One SPA component, one session.

When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).

🔗 **Session bundle — rule builder (#176 follow-ups):** #434, #435, #436, #437, #438 All frontend RuleBuilder follow-ups deferred from #176: facet-value typeahead (#434), relative-date operators (#435), deeper nesting (#436), inline adoption in ChannelBuilder & Auto-Tune (#437), input validation & polish (#438). One SPA component, one session. When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).
timothy added the in-progress label 2026-07-23 18:38:59 +02:00
Author
Owner

Claiming as part of a single-session RuleBuilder bundle sweep (#438 + #435 + #434). Building on one feature branch feat/rulebuilder-bundle (shared RuleBuilder.tsx makes splitting churny); #434 backend endpoint delegated to a parallel worktree. Design doc + spec to follow. Leaving #436 (deeper nesting, self-labeled YAGNI) and #437 (inline adoption) open.

Claiming as part of a single-session RuleBuilder bundle sweep (#438 + #435 + #434). Building on one feature branch `feat/rulebuilder-bundle` (shared `RuleBuilder.tsx` makes splitting churny); #434 backend endpoint delegated to a parallel worktree. Design doc + spec to follow. Leaving #436 (deeper nesting, self-labeled YAGNI) and #437 (inline adoption) open.
Author
Owner

Closing record

Outcome: Shipped in PR #577. New GET /api/v1/search/fields/{name}/values?q=&limit= returning distinct whole values from the database (per-field EF queries), allow-listed to facet fields; content_rating split on /; state/video_dynamic_range from fixed enums; case-insensitive prefix; limit clamped [1,50]. Frontend autocomplete combobox for text value inputs with a free-text fallback.
Root cause: N/A (new feature).
Decisions/conventions changed: added api.search-field-values (docs/decisions.md).
Reusable knowledge: analyzed Lucene TextFields yield only lowercased word tokens from the term dictionary ("Science Fiction" → science/fiction) — useless as whole-value typeahead. Source distinct values from the DB instead: the shared lookup entities (Genre/Tag/Studio/Director/Writer) are already deduped across all metadata via M2M, so dbContext.Set<Genre>().Select(g => g.Name).Distinct() is a single-table distinct (reach non-DbSet entities via Set<T>()). .ToLower().StartsWith(q) gives provider-portable case-insensitive SQL filtering. title/show_title excluded (near-unique free-text, not a facet); album_artist excluded (value-converted IList<string> column, not server-queryable).
Verification: C# 9/9 EF-backed handler tests; live-E2E (booted from source): supported fields 200, state/video_dynamic_range return whole values, case-insensitive prefix live, title/show_title/album_artist/non-text/unknown → 404. web 980/980. opus review of the DB-sourcing rework (MERGEABLE).
Deferred: combobox polish (empty-mount fetch, unmount guard) + artist/album_artist source completeness → follow-up #578.
Docs updated: docs/decisions.md (api.search-field-values), docs/api-conventions.md, docs/spa-conventions.md §12, regenerated OpenAPI (v1.json/v1.d.ts/endpoint-index.md).

## Closing record **Outcome:** Shipped in PR #577. New `GET /api/v1/search/fields/{name}/values?q=&limit=` returning **distinct whole values from the database** (per-field EF queries), allow-listed to facet fields; `content_rating` split on `/`; `state`/`video_dynamic_range` from fixed enums; case-insensitive prefix; `limit` clamped [1,50]. Frontend autocomplete combobox for text value inputs with a free-text fallback. **Root cause:** N/A (new feature). **Decisions/conventions changed:** added `api.search-field-values` (`docs/decisions.md`). **Reusable knowledge:** analyzed Lucene `TextField`s yield only lowercased word *tokens* from the term dictionary ("Science Fiction" → `science`/`fiction`) — useless as whole-value typeahead. Source distinct values from the DB instead: the shared lookup entities (Genre/Tag/Studio/Director/Writer) are already deduped across all metadata via M2M, so `dbContext.Set<Genre>().Select(g => g.Name).Distinct()` is a single-table distinct (reach non-DbSet entities via `Set<T>()`). `.ToLower().StartsWith(q)` gives provider-portable case-insensitive SQL filtering. `title`/`show_title` excluded (near-unique free-text, not a facet); `album_artist` excluded (value-converted `IList<string>` column, not server-queryable). **Verification:** C# 9/9 EF-backed handler tests; live-E2E (booted from source): supported fields 200, `state`/`video_dynamic_range` return whole values, case-insensitive prefix live, `title`/`show_title`/`album_artist`/non-text/unknown → 404. web 980/980. opus review of the DB-sourcing rework (MERGEABLE). **Deferred:** combobox polish (empty-mount fetch, unmount guard) + `artist`/`album_artist` source completeness → follow-up #578. **Docs updated:** `docs/decisions.md` (`api.search-field-values`), `docs/api-conventions.md`, `docs/spa-conventions.md` §12, regenerated OpenAPI (`v1.json`/`v1.d.ts`/`endpoint-index.md`).
timothy removed the in-progress label 2026-07-23 21:18:03 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#434