close
Skip to content

Nested Documents UI — Phase 1: Advanced AIP Search with Nested Filter Groups #3661

@luis100

Description

@luis100

Overview

Extend the advanced search panel for AIPs (AdvancedSearchFieldsPanel) to support a new nested_group field type. This renders a collapsible "Contains X where…" block with sub-fields that compile into a ParentWhichFilterParameter — finding parent AIPs whose nested children match the given criteria.

Note

ParentWhichFilterParameter is already fully serializable and passes through the existing /api/v2/aips/find endpoint without any backend changes. This is a pure configuration + GWT client change.

Part of: #3382
Depends on: #3660 (Phase 0 — for the emailarchive content_type value used in the parent filter)


How Nested Filter Groups Work

When a user fills in fields inside a nested group and clicks Search, the panel builds:

new ParentWhichFilterParameter(
  new SimpleFilterParameter("content_type", "emailarchive"),  // parentFilter (block mask)
  new AndFiltersParameters(filledChildFilters)                 // childrenFilter
)

This translates to a Solr block-join query that returns parent AIPs whose child email documents match the criteria. The result list continues to show IndexedAIP rows — the mailbox AIPs that contain matching emails.

Solr query generated (for reference)
{!parent which="content_type:emailarchive"} (subject_txt:quarterly AND sender_s:joao*)

Configuration Schema

File: roda-ui/roda-wui/src/main/resources/config/roda-wui.properties

New nested_group type added to ui.search.fields.IndexedAIP:

ui.search.fields.IndexedAIP = identifier, uuid, level, title, ..., email_nested_group

# The nested group field
ui.search.fields.IndexedAIP.email_nested_group.type                         = nested_group
ui.search.fields.IndexedAIP.email_nested_group.i18n                         = ui.search.fields.IndexedAIP.email_nested_group
ui.search.fields.IndexedAIP.email_nested_group.nested_parent_filter         = content_type:emailarchive
ui.search.fields.IndexedAIP.email_nested_group.nested_fields                = email_subject, email_sender, email_sentDate

# Sub-fields inside the nested group
ui.search.fields.IndexedAIP.email_nested_group.email_subject.fields         = subject_txt
ui.search.fields.IndexedAIP.email_nested_group.email_subject.type           = text
ui.search.fields.IndexedAIP.email_nested_group.email_subject.i18n           = ui.search.fields.IndexedAIP.email_nested_group.email_subject

ui.search.fields.IndexedAIP.email_nested_group.email_sender.fields          = sender_s
ui.search.fields.IndexedAIP.email_nested_group.email_sender.type            = text
ui.search.fields.IndexedAIP.email_nested_group.email_sender.i18n            = ui.search.fields.IndexedAIP.email_nested_group.email_sender

ui.search.fields.IndexedAIP.email_nested_group.email_sentDate.fields        = sentDate_dt
ui.search.fields.IndexedAIP.email_nested_group.email_sentDate.type          = date_interval
ui.search.fields.IndexedAIP.email_nested_group.email_sentDate.i18n          = ui.search.fields.IndexedAIP.email_nested_group.email_sentDate

Model Changes

File: roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/SearchField.java

Add three new fields to the SearchField POJO:

private boolean nestedGroup = false;
private String nestedParentFilter;          // e.g. "content_type:emailarchive"
private List<SearchField> nestedFields;     // sub-fields for the group

With corresponding getters, setters, and Jackson annotations.


AdvancedSearchFieldsPanel.java Changes

File: roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/search/AdvancedSearchFieldsPanel.java

1. getSearchFieldsFromConfig() — parse nested_group type

When a field has type = nested_group:

  • Set searchField.setNestedGroup(true)
  • Read nested_parent_filter value
  • Recursively parse the sub-fields listed in nested_fields (same property structure as regular fields, but prefixed under the group key)

2. Rendering — collapsible block

Render a nested group as a visually distinct collapsible block. When collapsed, shows "Contains email where…" label. When expanded, shows the sub-field rows (each using the standard field type renderers: text box, date picker, date interval, etc.).

3. Filter compilation on search

When the user clicks Search, detect which nested groups have at least one sub-field filled. For each filled group:

List<FilterParameter> childFilters = new ArrayList<>();
for (SearchField subField : nestedGroup.getNestedFields()) {
  FilterParameter fp = buildFilterForField(subField);  // existing logic
  if (fp != null) childFilters.add(fp);
}
if (!childFilters.isEmpty()) {
  filter.add(new ParentWhichFilterParameter(
    new SimpleFilterParameter(nestedGroup.getNestedParentFilter()),   // parentFilter
    new AndFiltersParameters(childFilters)                            // childrenFilter
  ));
}

Note

nestedParentFilter is stored as a raw Solr query string (e.g. content_type:emailarchive). It maps directly to ParentWhichFilterParameter.parentFilter as a SimpleFilterParameter. For the advanced search use case, only simple equality filters are needed as the block mask.


i18n Keys Required

ui.search.fields.IndexedAIP.email_nested_group = Contains Email where...
ui.search.fields.IndexedAIP.email_nested_group.email_subject = Subject
ui.search.fields.IndexedAIP.email_nested_group.email_sender = Sender
ui.search.fields.IndexedAIP.email_nested_group.email_sentDate = Sent Date

Files to Change

File Action
roda-ui/roda-wui/src/main/resources/config/roda-wui.properties Edit — add nested_group config for IndexedAIP
roda-common/roda-common-data/.../data/v2/index/SearchField.java Edit — add nestedGroup, nestedParentFilter, nestedFields
roda-ui/.../client/common/search/AdvancedSearchFieldsPanel.java Edit — parse and render nested groups, compile ParentWhichFilterParameter
All locale .properties files Edit — add i18n keys

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions