Skip to content

[feature] Search: discover searchable fields via /api/search/fields (Search-in picker)#37

Merged
joewiz merged 2 commits into
mainfrom
feature/search-field-picker
Jun 10, 2026
Merged

[feature] Search: discover searchable fields via /api/search/fields (Search-in picker)#37
joewiz merged 2 commits into
mainfrom
feature/search-field-picker

Conversation

@joewiz

@joewiz joewiz commented Jun 10, 2026

Copy link
Copy Markdown
Owner

[This PR was co-authored with Claude Code. -Joe]

Summary

Adds a "Search in:" picker to the Search dialog, populated from existdb-openapi's GET /api/search/fields?scope=/db. The endpoint lists the searchable fields / facets / vectors visible to the calling user (field-level security filters the list), each with its kind, source elements, type, analyzer, and returnable flag.

This is the discovery half of field-aware search. Per-field querying needs eXist-db/exist#6455 (today /api/search runs the default site-content field), so the picker is a preview for now — selecting a field doesn't yet scope the query. Wiring the selection in is the follow-up once #6455 lands.

What changed

  • ExistClient.searchFields(scope)SearchFields{scope, user, total, fields[]} with a SearchFieldInfo record (field, kind, elements, type, analyzers, returnable). The server reports analyzer as either a string or an array — normalized to a list. Unit-tested via the mock (facet + string-analyzer field + array-analyzer field + vector).
  • SearchDialog — a "Search in:" combo populated per selected server (off-EDT), sorted field → facet → vector, with the field's contract as a tooltip and an FLS hint ("N visible to <user>"). Re-discovers when the server changes. Older servers without the endpoint just show "All fields".

Test plan

  • mvn test green (incl. the new string-vs-array analyzer parse test); Codacy PMD clean.
  • Smoke (needs a server with ft:fields, e.g. the PoC bed :19109 added as a connection): open Search → the "Search in:" combo lists the fields; hover an item to see elements/type/analyzer; the hint shows the count + resolved user.
  • FLS: as admin the list is larger than as guest (12 vs 7 on the PoC bed).
  • Graceful degradation: against a server without /api/search/fields, the combo just shows "All fields" (no error).

Notes

PoC caveat: ft:fields (eXist-db/exist#6459) isn't in a released eXist; the discovery endpoint runs on the :19109 PoC bed. /api/search itself currently 500s on that bed, which is why this PR is discovery-only and doesn't touch the query path.

joewiz and others added 2 commits June 9, 2026 23:42
…Search-in picker)

Consume existdb-openapi's GET /api/search/fields?scope=… to populate a "Search in"
picker in the Search dialog. The endpoint returns the fields/facets/vectors visible
to the caller (field-level security filters the list), each with its kind, source
elements, type, analyzer, and returnable flag.

- ExistClient.searchFields(scope) -> SearchFields{scope,user,total,fields[]} with a
  SearchFieldInfo record. The server reports `analyzer` as either a string or an
  array; it's normalized to a list (covered by a unit test, with facet/field/vector
  and both analyzer shapes via the mock).
- SearchDialog: a "Search in:" combo populated per server (off-EDT), sorted
  field→facet→vector, with the contract shown as a tooltip and an FLS hint ("N
  visible to <user>"). Older servers without the endpoint just show "All fields".

Discovery only for now: per-field *querying* needs eXist-db/exist#6455 (today
/api/search runs the default field), so the selection is a preview — the combo's
tooltip says so. Wiring the selection into the query is the follow-up once #6455
lands.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… buttons

A WEST-placed status label takes its full preferred width, so a long
message — e.g. a 500's raw JSON body — overflowed and overlapped the
Cancel/Open buttons. Move the status to CENTER (it gets only the space
left after the buttons and clips) and keep the full error text on hover.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joewiz joewiz merged commit d406549 into main Jun 10, 2026
4 checks passed
@joewiz joewiz deleted the feature/search-field-picker branch June 10, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant