Skip to content

support 'negated' NestedFilters with 🆕 NegatedNestedFilter#4519

Merged
twrichards merged 1 commit intomainfrom
nested-field-negation
Sep 9, 2025
Merged

support 'negated' NestedFilters with 🆕 NegatedNestedFilter#4519
twrichards merged 1 commit intomainfrom
nested-field-negation

Conversation

@twrichards
Copy link
Copy Markdown
Contributor

Co-authored-by: @frederickobrien

As per https://trello.com/c/6YFv1T5L/955-feature-small-usages-searches-cant-be-used-in-exclusions until now we haven't been able to perform a negated search (a.k.a. NOT - signified by the - on the chip, rather than +) on usages@... (i.e. NestedFields because such a 'term' in the query was simply ignored, because there was no logic to deal with it and map/convert it to the ElasticSearch clause... this PR adds that logic 🎉

This also unblocks #3998 (as there we want to hide usage@status:replaced from search by default) which is somewhat urgent (so we don't need to merge #4498).

@twrichards twrichards requested a review from a team as a code owner September 5, 2025 15:32
Comment on lines +120 to +122
val queryWithNestedAndNormal = listOfNestedToQueries(nested).foldLeft(queryWithNormal) { case (q, nestedQ) => q.withMust(nestedQ) }

listOfNestedToQueries(negationNested).foldLeft(queryWithNestedAndNormal) { case (q, negNestedQ) => q.withNot(negNestedQ) }
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.

I can just about make out what's happening here but it could do with some more clarity?

@gu-prout
Copy link
Copy Markdown

gu-prout Bot commented Sep 9, 2025

Seen on auth, usage, image-loader, metadata-editor, thrall, leases, cropper, collections, media-api, kahuna (merged by @twrichards 11 minutes and 52 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants