Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for quoted (default) MongoDB search term values in SearchQueryParser #21567

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

danotorrey
Copy link
Contributor

@danotorrey danotorrey commented Feb 7, 2025

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

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@danotorrey danotorrey requested review from kingzacko1, luk-kaminski and a team February 7, 2025 21:21
@danotorrey danotorrey changed the title Add support for quoted (default) search term values in SearchQueryParser Add support for quoted (default) MongoDB search term values in SearchQueryParser Feb 7, 2025
@kingzacko1
Copy link
Contributor

Old:
image
New:
image

Nice work. LGTM!

@danotorrey danotorrey merged commit 32fbea9 into master Feb 11, 2025
8 checks passed
@danotorrey danotorrey deleted the fix/support-quoted-terms-for-default-terms branch February 11, 2025 17:17
garybot2 pushed a commit that referenced this pull request Feb 11, 2025
…QueryParser (#21567)

* Add support for quoted default search term values

* Add change log

* Cleanup

(cherry picked from commit 32fbea9)
garybot2 pushed a commit that referenced this pull request Feb 11, 2025
…QueryParser (#21567)

* Add support for quoted default search term values

* Add change log

* Cleanup

(cherry picked from commit 32fbea9)
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.

SearchQueryParser splits quoted search term when default field is searched
2 participants