[Cases][Templates] Extend cases search by template field label#266414
Conversation
|
Pinging @elastic/kibana-cases (Team:Cases) |
|
@elasticmachine merge upstream |
22bff01 to
1fe492b
Compare
| * - exact tokens: full label must equal the token text | ||
| * - substring tokens (quoted): label must contain the token text | ||
| */ | ||
| export const resolveFieldLabelSearch = ( |
There was a problem hiding this comment.
🟠 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.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Page load bundle
History
|
…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) ...
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
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.