Apply excluded event IDs as a must_not -> terms filter - #27400
Open
dennisoelkers wants to merge 6 commits into
Open
dennisoelkers wants to merge 6 commits into
dennisoelkers wants to merge 6 commits into
Conversation
Event searches that exclude a set of event IDs inlined them into the Lucene query string as "NOT (id:a OR id:b ...)". OpenSearch rejects any query_string longer than search.query.max_query_string_length (32000 characters by default) with "Failed to parse query", so such a search failed outright once the exclusion set reached roughly 969 IDs. Carry the IDs on EventsSearchFilter instead and let the storage adapters apply them as a must_not terms filter, which is not subject to that limit. The new adapter parameter is added behind a defaulting overload so existing callers are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Full backend tests could only seed MongoDB from a static fixture file. Generating the ~1000 documents needed to exercise the security events "New" status filter that way would mean committing about a megabyte of generated JSON, so surface the collection that MongoDBTestService already holds and let such tests build their documents in code. Also shortens the comments added along with the must_not terms filter. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…-new-status-filter-query-length
excludedIds is computed server-side and never sent by a client, but exposing it as a JSON property added a required excluded_ids field to the generated TypeScript type, breaking the frontend type check at two call sites that build an EventsSearchFilter. Mark it @JsonIgnore so the REST contract is unchanged; the field is still carried in-process from the security events code down to the adapters. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
janheise
approved these changes
Sep 17, 2026
janheise
left a comment
Contributor
There was a problem hiding this comment.
LGTM, with manual testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: This needs a backport to previous versions.
Description
Motivation and Context
Event searches that exclude a set of event IDs (e.g. filtering for
NEWevents) inlined them into the Lucene query string asNOT (id:a OR id:b ...). OpenSearch rejects anyquery_stringlonger thansearch.query.max_query_string_length(32000 characters by default) withFailed to parse query, so such a search failed outright once the exclusion set reached roughly 969 IDs.This PR is raising the ceiling for this, by using a must_not terms filter, which is not subject to that limit (instead, the terms limit applies, which defaults to 64k actual terms).
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: