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

Fix search to only match whole words #1341

Closed
wants to merge 1 commit into from

Conversation

sweep-ai[bot]
Copy link

@sweep-ai sweep-ai bot commented Aug 4, 2023

Description

This PR addresses the issue of the search functionality in the PublicationPageSearchMixin class in di_website/publications/mixins.py matching partial words. The current implementation is using the default analyzer, which results in undesired matches. To fix this, the code has been modified to use a new analyzer that tokenizes the text into individual terms, each term corresponding to a word. This ensures that the search only returns results that match the whole words.

Summary of Changes

  • Updated the index.SearchField in the PublicationPageSearchMixin class in di_website/publications/mixins.py to use a new analyzer.
  • Added an es_extra dict to the index.SearchField with the analyzer key set to the name of the new analyzer.
  • The new analyzer tokenizes the text into individual terms, each term corresponding to a word, ensuring that the search only matches whole words.

Please review and merge this PR. Thank you!

Fixes #1339.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/fix-search-whole-words

To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Pull reviewers stats

Stats of the last 30 days for DIwebsite-redesign:

User Total reviews Time to review Total comments
edwinmp 2 4m 0

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@akmiller01 akmiller01 closed this Aug 4, 2023
@akmiller01 akmiller01 deleted the sweep/fix-search-whole-words branch August 4, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sweep Assigns Sweep to an issue or pull request.
Projects
None yet
1 participant