Skip to content

[Cases][Templates] Extend cases search by template field label#266414

Merged
MykhailoKondrat merged 2 commits intoelastic:mainfrom
MykhailoKondrat:feature/search-cases-by-template-field-name
May 5, 2026
Merged

[Cases][Templates] Extend cases search by template field label#266414
MykhailoKondrat merged 2 commits intoelastic:mainfrom
MykhailoKondrat:feature/search-cases-by-template-field-name

Conversation

@MykhailoKondrat
Copy link
Copy Markdown
Contributor

What & Why

Extends the Cases search bar to also match against template extended field labels. Previously, free-text input only searched title, description, and incremental ID. Now the server tokenizes the search string and checks each token (substring match) against known template field labels — returning cases that have any extended field whose label contains the search term. Quoted phrases like "Start date" are treated as a single multi-word token. Results are OR'd with the existing free-text search, so no existing behavior changes. The search bar placeholder was updated to communicate all three capabilities: free text, field label, and field:value filtering.

How to Test

  • Create a template with extended fields (e.g., "Priority", "Start date operation", "End date").
  • Create cases using that template and fill in the extended fields.
  • Type priority in the All Cases search bar — cases with a "Priority" field should appear alongside title/description matches.
  • Type start — cases with fields containing "start" in the label (e.g., "Start date operation") should appear, but not "End date".
  • Type "start date" (with quotes) — only fields whose label contains the phrase "start date" should match.
  • Combine: priority:high network should filter by Priority=high AND return cases matching "network" in title/description or as a field label.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

@MykhailoKondrat MykhailoKondrat requested a review from a team as a code owner April 29, 2026 14:27
@MykhailoKondrat MykhailoKondrat added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Cases Security Solution Cases team Cases: Templates Development of cases templates system Feature - improved case templates labels Apr 29, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/kibana-cases (Team:Cases)

@MykhailoKondrat
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@MykhailoKondrat MykhailoKondrat force-pushed the feature/search-cases-by-template-field-name branch from 22bff01 to 1fe492b Compare May 4, 2026 17:56
* - exact tokens: full label must equal the token text
* - substring tokens (quoted): label must contain the token text
*/
export const resolveFieldLabelSearch = (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High cases/extended_field_search_utils.ts:344

When the same storageKey appears under multiple labels (e.g., "Priority" and "Priority Level" both mapping to priority_as_keyword), the deduplication at line 373 discards all but the first match using seen.has(meta.storageKey). This loses templateVersions from the discarded matches, so buildFieldLabelExistsClauses generates queries that omit those template versions—cases created with those templates won't be found. Consider merging templateVersions arrays when deduplicating instead of skipping entirely.

🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/platform/plugins/shared/cases/server/services/cases/extended_field_search_utils.ts around line 344:

When the same `storageKey` appears under multiple labels (e.g., "Priority" and "Priority Level" both mapping to `priority_as_keyword`), the deduplication at line 373 discards all but the first match using `seen.has(meta.storageKey)`. This loses `templateVersions` from the discarded matches, so `buildFieldLabelExistsClauses` generates queries that omit those template versions—cases created with those templates won't be found. Consider merging `templateVersions` arrays when deduplicating instead of skipping entirely.

Evidence trail:
x-pack/platform/plugins/shared/cases/server/services/cases/extended_field_search_utils.ts lines 302-338 (buildLabelToMetasIndex - separate entries per label, each with own templateVersions), lines 344-385 (resolveFieldLabelSearch - dedup with seen.has drops subsequent entries), lines 412-440 (buildFieldLabelExistsClauses - uses templateVersions to build query filters). All at REVIEWED_COMMIT.

@kibanamachine
Copy link
Copy Markdown
Contributor

kibanamachine commented May 4, 2026

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #184 / Entity Analytics - Entity Resolution @ess @serverless @skipInServerlessMKI Entity Resolution CSV Upload "before all" hook for "should link matching entities to a target"
  • [job] [logs] FTR Configs #184 / Entity Analytics - Entity Resolution @ess @serverless @skipInServerlessMKI Entity Resolution CSV Upload "before all" hook for "should link matching entities to a target"

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 172.0KB 172.1KB +31.0B

History

@MykhailoKondrat MykhailoKondrat merged commit 20dcc2d into elastic:main May 5, 2026
25 checks passed
mbondyra added a commit to mbondyra/kibana that referenced this pull request May 5, 2026
…ilder_new_vis_attachment

* commit '6fd683609eb6dee81f242f8ff6951edbe3bfd66c': (226 commits)
  Remove Model Author group-by option from external inference endpoints (elastic#264761)
  [Streams][Streamlang] Align ES|QL condition transpiler with Painless on null propagation (elastic#264751)
  chore(axios,workflows-eng): remove axios from workflows connector utils (elastic#267512)
  [failed-test-reporter] avoid opening issues for scout env failures (elastic#267649)
  [kbn-api-contracts] Detect request-body additionalProperties:false tightening (elastic#267546)
  [main] Sync bundled packages with Package Storage (elastic#267644)
  Centralize phase colors and descriptions (elastic#266680)
  [Unified Waterfall] Add "Scroll to origin" button  (elastic#266594)
  [APM] Add alert and SLO badges to the service map embeddable (elastic#266360)
  [CI] Speed up telemetry_check by pre-filtering to collector files (elastic#265978)
  [Discover] Address flaky large CSV test (elastic#266642)
  avoid passing unrelated props within integration card icon component conditional render (elastic#266569)
  [Cases][Templates] Extend cases search by template field label (elastic#266414)
  [Background search] Migrate custom SplitButton to EuiSplitButton (elastic#267447)
  [i18n] Report translation coverage during integrate (elastic#264124)
  [api-docs] 2026-05-05 Daily api_docs build (elastic#267639)
  [Scout] Update test config manifests (elastic#267636)
  [content list] Add saved object provider services (elastic#266428)
  [Fleet] Otel UI add health and implement it in OTelComponentDetail (elastic#267292)
  Update dependency msw to v2.13.4 (main) (elastic#266770)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Cases: Templates Development of cases templates system Feature - improved case templates release_note:skip Skip the PR/issue when compiling release notes Team:Cases Security Solution Cases team v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants