Add support for quoted (default) MongoDB search term values in SearchQueryParser #21567
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.
Description
Add support for quoted default search terms (those that don't specifically indicate a field name) when performing entity searches on various pages throughout the application where the MongoDB
SearchQueryParser
is used. The underlaying problem is explained in detail in the source issue #21565.TLDR: When multi-word entity search terms are provided in quotes (e.g.
"My Event Definition"
), they will no longer be split into separate search terms by word. This prevents an excessive number of results from being returned, which can be confusing (and not what I think folks will expect). The words are still split into separate terms when no quotes are supplied.This also adds consistency with how field-specific terms work and respect quotes. For example, currently, when searching for
title:"My Event Definition"
, only the whole quoted value is searched. It seems to follow that non-field specific values should work the same way.Note that I am not a regex expert, but I did try to break-up the long splitting expression into chunks with corresponding documentation to improve maintainability. Please let me know if anyone has advice for improving the expression
Motivation and Context
Fixes #21565
This issue was discovered while providing support assistance. I have also noticed this in the past, so I thought this was a good chance to dig-into it and see if we can improve quoted search term handling.
How Has This Been Tested?
There is pretty extensive unit test coverage for
SearchQueryParser
. I've added two tests for the new cases and confirmed that over cases still pass. I also have done some smoke-testing when searching for Event Definitions, and it seems to work fine.Screen Shots
Types of changes
Checklist: