Fix issue with adding negating scripted filter #4991
Merged
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.
Closes #4890.
Prior to these changes, when you would use the magnifying glass buttons in discover to add a field filter on a scripted field, then again to add a negating field filter on the same field, it wasn't having any effect.
We have special logic for this situation. If a user adds a field filter, then adds a negating field filter on the same field, we can safely assume they don't actually want two conflicting field filters, so we identify the existing field filter and simply update the existing field filter and negate it.
However, the code that accomplishes this was not considering scripted fields, so it was not properly identifying that there was an existing field filter for scripted fields.
This PR fixes it so it correctly identifies when a scripted field filter on the same field already exists, and adds a test case.