Skip to content

fix: require wildcard mappings across all queried indices in wildcard search mode - #3987

Open
jaegeral wants to merge 2 commits into
google:masterfrom
jaegeral:2026-11-23_ip-wildcard-search
Open

jaegeral wants to merge 2 commits into
google:masterfrom
jaegeral:2026-11-23_ip-wildcard-search

Conversation

@jaegeral

Copy link
Copy Markdown
Collaborator

Summary

Fixes mixed wildcard / non-wildcard timelines silently returning 0 hits in Wildcard (WC) search mode:

  • Require all queried indices to support wildcard mappings (timesketch/lib/datastores/opensearch.py):
    • OpenSearchDataStore.get_wildcard_fields() previously took the union of wildcard fields across all indices even when one or more indices lacked .wildcard subfields (e.g., pre-wildcard timelines or Manual events). That kept meta.supports_wildcard = True on mixed sketches and caused Wildcard queries to silently return 0 hits for non-wildcard timelines while Query String (QS) mode returned all hits.
    • get_wildcard_fields() now returns [] whenever any queried index has no mappings/properties or zero wildcard fields, while preserving the union of wildcard fields when all queried indices support wildcard search (so heterogeneous schemas such as EVTX + HTTP timelines retain all of their wildcard fields).
  • Guard Explore.vue searchMode getter on meta.supports_wildcard (timesketch/frontend-ng/src/views/Explore.vue):
    • Checks !this.meta || !this.meta.supports_wildcard before consulting localSearchMode so adding a non-wildcard timeline immediately falls back to query_string.

Testing

  • Backend unit tests (timesketch/lib/datastores/opensearch_test.py): added test_get_wildcard_fields_mixed_indices and test_get_wildcard_fields_multiple_wildcard_indices (covering mixed indices, union across distinct wildcard-enabled indices, and missing mappings).
  • API E2E (end_to_end_tests/wildcard_query_test.py): added test_wildcard_ip_search_mixed_indices checking supports_wildcard is False and explore_wildcard rejects mixed indices rather than silently returning 0 hits.
  • Playwright UI E2E (end_to_end_tests/ui_test.py): added test_08_mixed_timelines_wildcard_ip_search testing a mixed CSV + Manual events sketch disables Wildcard mode and finds *<ip>* matches in Query String mode.
  • Linters: black --check, pylint --rcfile=.pylintrc, and yarn run eslint passed with 0 errors.

@jaegeral

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates Timesketch to disable wildcard search mode on sketches that mix wildcard-mapped and non-wildcard-mapped indices, preventing wildcard queries from silently returning zero hits. It includes backend updates to the OpenSearch datastore, frontend adjustments to default to query string mode, and new end-to-end and unit tests. Feedback on the changes identifies a potential AttributeError in timesketch/lib/datastores/opensearch.py when retrieving properties from index mappings, recommending defensive dictionary checks to prevent potential API crashes.

Comment thread timesketch/lib/datastores/opensearch.py Resolved
@jaegeral
jaegeral force-pushed the 2026-11-23_ip-wildcard-search branch from 9b055d3 to 3cfa330 Compare November 23, 2026 16:30
…ests

- Preserve wildcard mode when an empty/buffering generic.mappings index has wildcard dynamic_templates and no non-wildcard text fields yet
- Tighten legacy ES 6.x fallback to select only dicts containing properties
- Add set[str] type annotations and update get_wildcard_fields docstring
- Add Vitest coverage for Explore.vue searchMode fallback when supports_wildcard is false
- Poll for OpenSearch refresh in ui_test.py and tighten E2E assertions in wildcard_query_test.py
@jaegeral jaegeral self-assigned this Nov 24, 2026
@jaegeral
jaegeral requested a review from berggren November 24, 2026 09:53

This branch has not been deployed

No deployments
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.

2 participants